PostgreSQL: FATAL: password authentication failed for user
PostgreSQL rejected the password for that role, or pg_hba.conf requires a different auth method.
Meaning
PostgreSQL checks pg_hba.conf to choose the auth method per connection type/host/user, then validates the password. A mismatch between md5 and scram-sha-256 password storage is a common cause after upgrades.
Common causes
- Wrong password or role name
- Role has no password set (peer auth works locally, password doesn’t)
- pg_hba.conf method/host line doesn’t match the connection
- Password stored as md5 but pg_hba requires scram-sha-256
- Docker
POSTGRES_PASSWORDchanged after volume initialized
⚡ Quick fix
- Reset the password:
ALTER ROLE app WITH PASSWORD '…'; - Check pg_hba.conf lines and reload Postgres
- Re-set passwords after switching to scram-sha-256
Detailed fix by platform
PostgreSQL
- Reset password as postgres superuser:bash
sudo -u postgres psql -c "ALTER ROLE app WITH LOGIN PASSWORD 'NewStrongPass';" sudo -u postgres psql -c "SHOW hba_file;" sudo systemctl reload postgresql
How to diagnose
- Role — Exists with LOGIN?
- pg_hba — Which line matches this connection?
- Method — md5 vs scram-sha-256?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026