Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when connecting to redshift: "server certificate does not match host name"

After trying to run a query on redshift, I get the following error message:

OperationalError: (psycopg2.OperationalError) server certificate for "" does not match host name "".

I already installed the sqlalchemy-redshift package, as well as the Psycopg2 package. My code:

from sqlalchemy import create_engine

def run_query(query, connection_string):

 red_engine = create_engine(connection_string)
 data_set = pd.read_sql_query(query, red_engine)

 return data_set

The exact same code does work on another computer, so we are sure that the login name, password and queries are correct, and the problem is specific to my computer. Any suggestions?

like image 484
Tettje Avatar asked Sep 04 '17 08:09

Tettje


1 Answers

This worked for me in the end: we added a preferred sslmode to our code, as follows:

create_engine(connection_string, connect_args={'sslmode': 'prefer'})
like image 62
Tettje Avatar answered Sep 21 '22 06:09

Tettje