Skip to main content
postgresqlbeginnerauthenticationVerified

PostgreSQL Password Authentication Failed: Causes and Fixes

Last reviewed: 9/14/2026
3 solutions

Exact Error Message

password authentication failed for user

Quick Fix

Reset user password or check pg_hba.conf authentication method: ALTER USER username WITH PASSWORD 'newpassword';

What This Error Means

Password authentication failed occurs when PostgreSQL cannot verify the user's password. This can be due to wrong password, user not existing, or pg_hba.conf authentication method misconfiguration.

Common Symptoms
  • Cannot connect to database
  • Password authentication failed error
  • psql prompts for password but rejects it
  • Application connection fails
Common Causes
  • Incorrect password provided
  • User does not exist in database
  • pg_hba.conf using wrong auth method
  • Case sensitivity in username
  • Password expired or needs reset
  • Connecting to wrong database
Diagnostic Steps
  1. 1Verify username and password are correct
  2. 2Check if user exists in PostgreSQL
  3. 3Review pg_hba.conf authentication methods
  4. 4Test connection with psql directly
  5. 5Check PostgreSQL logs for auth errors

Solutions

Solution 1: Start PostgreSQL service
  1. 1Check service status
  2. 2Start PostgreSQL if stopped
  3. 3Enable auto-start on boot
  4. 4Verify service is listening

Commands to Run

Starting PostgreSQL service requires appropriate permissions

sudo systemctl status postgresql
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo netstat -tlnp | grep 5432
Solution 2: Fix pg_hba.conf access rules
  1. 1Locate pg_hba.conf file
  2. 2Review current access rules
  3. 3Add or modify host entries
  4. 4Reload PostgreSQL configuration

Commands to Run

Incorrect pg_hba.conf settings can lock you out

sudo nano /etc/postgresql/VERSION/main/pg_hba.conf

Always test changes before reload

sudo systemctl reload postgresql
Solution 3: Fix listen_addresses configuration
  1. 1Edit postgresql.conf
  2. 2Set listen_addresses to include desired IPs
  3. 3Reload PostgreSQL
  4. 4Test connection

Commands to Run

Changing auth methods affects all connections

sudo nano /etc/postgresql/VERSION/main/pg_hba.conf

Test changes before reload

sudo systemctl reload postgresql
Prevention Tips
  • Use strong passwords
  • Rotate passwords regularly
  • Use environment variables for passwords
  • Never commit passwords to version control
  • Use connection pooling to reduce auth overhead

Version Notes: Applies to PostgreSQL 12+

Was this helpful?