FATAL: password authentication failed for user “postgres”

In this article, we will see the solution for error “FATAL: password authentication failed for user “postgres””.

FATAL:  password authentication failed for user "postgres"

1. Reason is the user postgres has no DB password set on Ubuntu by default. That means, that you can login to that account only by using the postgres OS user account.

sudo -u postgres psql

2. Now set the password for user ‘postgres’;

alter user postgres with password 'admin@123';

3. If any of those commands fail with an error psql: FATAL: password authentication failed for user “postgres” then check the file /etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:

local all postgres ident

Reload postgresql server after modifying pg_hba.conf file.