dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
dbaguide.com
Home/Error Library/postgresql-password-authentication-failed
PostgreSQL
PG 14 - 17Authentication & Security
4 min read
FATAL: password authentication failed for user

psql "password authentication failed for user" — Bad Password or pg_hba.conf Rule?

Four root causes of psql password authentication failed: incorrect password, md5/SCRAM mismatch, pg_hba.conf rule ordering, and port/cluster confusion. Step-by-step triage.

Reviewed by:Senior Database Architect & SRE (dataiotech Labs)
Tested Versions: PostgreSQL 14.10, 15.6, 16.4, 17.0 (Ubuntu 24.04 LTS / Docker 26.1)

Operational Verification & Reliability Metadata

Last Technical Review: 27 Ekim 2026
Tested VersionsPostgreSQL 14.10, 15.6, 16.4, 17.0 (Ubuntu 24.04 LTS, Docker 26.1, Kernel 6.8)
Required PrivilegesSUPERUSER or pg_read_all_stats / pg_signal_backend
Risk Assessment
MediumTerminating active sessions forces application-layer transaction rollbacks
Expected OutputTotal connections drop safely below max_connections threshold in pg_stat_activity
Rollback Procedure:Reset temporary session timeouts, reload PgBouncer or revert pool sizing
PostgreSQL Docs: Connections
First 60 Seconds Emergency Protocol:

The error string is a symptom, not the root cause. Do not restart the server blindly. Run the diagnostic queries below to pinpoint the actual failure mode.

▸Symptom

plaintext
FATAL: password authentication failed for user "postgres"

PostgreSQL intentionally obscures authentication failure details to prevent user enumeration. The error can stem from an outdated password hash algorithm, unmatched pg_hba.conf rules, or cached credentials.


▸Key Diagnostic Steps

1. Inspect hash storage:

sql
SELECT rolname, left(rolpassword, 14) AS hash_type FROM pg_authid WHERE rolname = 'postgres';

2. Check effective pg_hba rules:

sql
SELECT rule_number, type, database, user_name, address, auth_method FROM pg_hba_file_rules ORDER BY rule_number;

3. Reset password using SCRAM-SHA-256:

sql
SET password_encryption = 'scram-sha-256'; ALTER USER postgres WITH PASSWORD 'your-strong-password';

Other Database Error Triage Playbooks

Other battle-tested diagnostic guides for high-severity database errors.

All Errors (20)