psycopg / psycopg2

PostgreSQL database adapter for the Python programming language

Home Page:https://www.psycopg.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: password authentication failed for user "postgres"

brunolnetto opened this issue · comments

Please complete the following information:

  • OS: Ubuntu 22.04
  • Psycopg version: 3.1.19
  • Python version: Python 3.10.12
  • PostgreSQL version: 13
  • pip version: 24.0

Describe the bug
Please let us know:

1: Please, take a look at the link below. In this application, I utilize library psycopg2 to connect to the database and perform queries.

https://github.com/brunolnetto/RF_CNPJ/blob/0bb33b6fed9781a643b13333f2047f9ce1dca94f/src/core/setup.py#L51

2: I expected to be able to at least instanciate a session and execute some operation.
3: I got an exception 'OperationalError'.

connection to server at "localhost" (127.0.0.1), port 5433 failed: FATAL: password authentication failed for user "postgres"

If possible, provide a script reproducing the issue. The source code is available on . To reproduce only the required script, run from folder src.

from core.setup import setup_database

setup_database()

It does not seem a problem on reproduction. I tested locally on my machine, and got the same issue. I guess, it is an role issue.

Not a psycopg issue.

I even wrote an issue on Stack Overflow threads [1] about the topic, without response so far. Would you mnid taking a look, please?

[1] https://stackoverflow.com/questions/78477505/psycopg2-connection-to-server-at-localhost-1-port-5432-failed-cannot-as

What you require is a professional consultancy about how to connect to a database.

Please get in touch privately to discuss my hourly rate.

I am a student, I cannot afford more than I can pay my rent. Sorry.

Then you can find documentation online for what you are looking for.

I reproduce the content I find, like this [1], without much of success. I suppose, you are able to fix the code. Thanks for even answering.

[1] https://www.docker.com/blog/how-to-use-the-postgres-docker-official-image/