FATAL: password authentication failed for user "postgres"
Most likely cause: Incorrect or empty password provided in the connection string or environment variable
Try first: Check the password in your code or config
Likely causes
- Incorrect or empty password provided in the connection string or environment variablemost likely
- The postgres user has no password set or uses peer/ident authentication instead of passwordpossible
- Connecting to the wrong database server or portless likely
How to fix it
Check the password in your code or configSafe
Look for the connection string or PG_PASSWORD / DATABASE_URL variable and make sure it matches the actual password for the postgres user.
Test the password from the command lineChanges settings
Run psql -U postgres and enter the password when prompted. If it fails, reset the password using the postgres service account.
⚠ You must have local access to the server running PostgreSQL.
Reset the postgres passwordChanges settings
As the system postgres user, run psql and execute ALTER USER postgres WITH PASSWORD 'newpassword'; then update your application config to match.
⚠ Changing the database password will break any other services still using the old one.
If that didn't fix it
Check the PostgreSQL log file (usually postgresql.log) for the exact authentication method that rejected the connection.
When to see a technician
Get help if you do not have direct access to the server running PostgreSQL or if this is a managed database service.
Quick answers
- What does FATAL: password authentication failed for user "postgres" mean?
- PostgreSQL rejected the login because the password supplied for its default superuser account named postgres was wrong or missing. This usually happens in code or scripts that connect to a database.
- What causes FATAL: password authentication failed for user "postgres"?
- Incorrect or empty password provided in the connection string or environment variable. (most likely) The postgres user has no password set or uses peer/ident authentication instead of password. (possible) Connecting to the wrong database server or port. (less likely)
- How do I fix FATAL: password authentication failed for user "postgres"?
- Try these in order, safest first: 1. Check the password in your code or config. 2. Test the password from the command line. 3. Reset the postgres password.
- What if that didn't fix it?
- Check the PostgreSQL log file (usually postgresql.log) for the exact authentication method that rejected the connection.
- When should I see a technician?
- Get help if you do not have direct access to the server running PostgreSQL or if this is a managed database service.