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