Database Diagnostic

Fix PostgreSQL "password authentication failed for user 'postgres'"

The PostgreSQL server rejected client authentication because the supplied password does not match the password stored in pg_shadow, or pg_hba.conf rules reject the authentication method.

error: password authentication failed for user "postgres"

Quick Fix Checklist

  1. Reset password via psql: sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'newpassword';"
  2. URL encode special characters in passwords (e.g. "@" becomes "%40", "#" becomes "%23")
  3. In pg_hba.conf: Change peer to md5 or scram-sha-256 for local socket connections
  4. Restart PostgreSQL: sudo systemctl restart postgresql