0

I'm trying to connecto to local PostgreSQL database (Windows 10) using psycopg2.

con = psycopg2.connect( database="postgres", user="postgres", password="*******", host="localhost", port="5432" ) 

I keep receiving not very informative OperationalError:

 --------------------------------------------------------------------------- OperationalError Traceback (most recent call last) <ipython-input-8-198849577200> in <module> ----> 1 con = psycopg2.connect( 2 database="postgres", 3 user="postgres", 4 password="******", 5 host="localhost", ~\Anaconda3\envs\py38\lib\site-packages\psycopg2\__init__.py in connect(dsn, connection_factory, cursor_factory, **kwargs) 125 126 dsn = _ext.make_dsn(dsn, **kwargs) --> 127 conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 128 if cursor_factory is not None: 129 conn.cursor_factory = cursor_factory OperationalError: 

Tryed to replace "localhost" by "127.0.0.1" with the same result. I see the database in psql with 5432 port and the same configuration. Any ideas what went wrong?

5
  • Impossible to tell what the error is without any stack trace. Are you sure all the credentials are correct, including your password Commented Apr 18, 2020 at 5:43
  • @AzyCrw4282 Yes. Doublechecked the credentials with psql... Can you suggest how to trace the stack? Commented Apr 18, 2020 at 6:12
  • Try looking at the postgres logs to see what it said happened. You can find them by executing SHOW log_directory; in psql. Commented Apr 18, 2020 at 6:22
  • Thanks for the suggestion. In the log there is an issue: 'FATAL: unsupported frontend protocol 1234.5679: server supports 2.0 to 3.0' Looks like a bug of PostgreSQL 12 Commented Apr 18, 2020 at 8:04
  • The work around is setting sslmode="disable" in psycopg2 Commented Apr 18, 2020 at 8:08

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.