0

I've been struggling with an error while trying to log into PostgreSQL:

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

Despite changing the postgres password, the error persisted. After investigating, I found the solution and wanted to share it for anyone facing a similar issue:

  1. Check PostgreSQL Configuration: I checked the PostgreSQL configuration file to verify the port number:
sudo nano /etc/postgresql/16/main/postgresql.conf
  1. Port Number Issue: I discovered that PostgreSQL 16 was set to run on port 5433 instead of the default port 5432:
port = 5433
  1. Connect Using the Correct Port: To connect to PostgreSQL, I specified the port explicitly in my connection command:
psql -h localhost -U postgres -p 5433

After making this adjustment, I was able to log in successfully.

I hope this helps anyone encountering the same issue! If anyone has further insights or suggestions, please feel free to share.

1
  • No, the issue is there is a Postgres server running on port 5432, use pg_lsclusters to see it. You need to determine which one you actually want to connect to. Commented Jul 9 at 18:18

0

Browse other questions tagged or ask your own question.