- Software and digital services
- Databases
28P01
PostgreSQL 28P01 database error: password login rejected
Evidence linked to this decision
View source: PostgreSQL 18 Appendix A: Error CodesRisk level
High
Professional inspection is recommended.
Urgency
Medium
Quick answer
SQLSTATE 28P01 (invalid_password) means the PostgreSQL server received the connection request but rejected the password for that database role. Check the target host, port, database, username, and active password source before retrying.
Safety first
Stop and check this first
- Do not let applications retry a rejected password in a tight loop, and never paste database passwords or unredacted connection URIs into support tickets or logs.
- Never change pg_hba.conf to trust or send unencrypted password authentication over untrusted networks to silence 28P01; trust lets anyone who can reach the server log in as any PostgreSQL user without a password.
Safe checks you can perform
- Verify target host, port, database, and role name in the failing runtime
- Check .pgpass, pgpass.conf, or PGPASSFILE ordering and Unix permissions
- Inspect the server log, pg_hba_file_rules, and pg_authid status
Leave these tasks to a qualified professional
- Do not attempt this professional task: Set or rotate the role password with scram-sha-256 encryption
- Do not attempt this professional task: Correct pg_hba.conf record order and reload server configuration
What a technician must be able to justify
Technician visit
These are the steps they must carry out and show you. Tick them as they work: if steps are skipped, do not accept a part swap.
These are not instructions for opening or handling the equipment yourself. They are the checks that should support a technical conclusion.
Set or rotate the role password with scram-sha-256 encryption
What they doHave the DBA verify password_encryption = 'scram-sha-256', set a new password for the LOGIN role using ALTER ROLE or the psql \password command, and update the application secret store.
They must show youthe current SHOW password_encryption value and a successful login test from the application runtime using the updated credential.
In writingthe role name updated, the password_encryption setting verified, and the secret rotation timestamp without recording the password.
Correct pg_hba.conf record order and reload server configuration
What they doHave the DBA adjust the authentication record order or method in pg_hba.conf, verify that pg_hba_file_rules reports no error fields, and apply the change with pg_ctl reload or SELECT pg_reload_conf().
They must show youthe active row in pg_hba_file_rules with a null error column after running pg_reload_conf().
In writingthe exact line number, connection type, database, user, address, and auth-method applied in pg_hba.conf.
Before accepting a part or repair
Nothing has been shown yet. Do not accept a part swap based on the code alone.
Follow these steps
Note: Follow the documented order. An error code identifies the affected system, but it does not prove by itself which part has failed.
Verify target host, port, database, and role name in the failing runtime
- Who:
- You or your application developer checks the runtime connection settings.
- How:
- Inspect the effective host, hostaddr, port, database name, and database user name configured for the failing service without printing the secret value, remembering that omitting the database name defaults to the database user name.
- Result that matters:
- Whether the connection parameters point to the intended PostgreSQL cluster and role.
- If the host, port, or user name points to another environment or role, that confirms a target configuration mismatch where a valid password was sent to the wrong server.
- If the endpoint and role name match the intended database server, that rules out wrong routing and points to the effective password source or server pg_authid record.
- Evidence to keep:
- Record the redacted host, port, database name, role name, and failure timestamp.
Evidence: PostgreSQL client authentication · PostgreSQL 18 authentication problems
Check .pgpass, pgpass.conf, or PGPASSFILE ordering and Unix permissions
- Who:
- Your developer or operator inspects the client runtime environment.
- How:
- Check whether the client uses passfile, PGPASSFILE, ~/.pgpass on Unix, or %APPDATA%\postgresql\pgpass.conf on Windows, inspect the order of hostname:port:database:username lines without exposing passwords, and check file mode on Unix.
- Result that matters:
- Which line matches first and whether Unix permissions disallow access to group and world.
- If a wildcard * line appears before the specific host entry, that confirms libpq is picking an earlier password line and indicates you must put more-specific entries first.
- If Unix file permissions are less strict than 0600, that confirms libpq ignores ~/.pgpass and explains why the expected credential was not sent.
- Evidence to keep:
- Keep the password file path, matching line number, and numerical file permissions without copying any password text.
Never print or paste plaintext passwords from .pgpass or pgpass.conf into tickets, chat channels, or logs.
Evidence: PostgreSQL 18 libpq password file
Inspect the server log, pg_hba_file_rules, and pg_authid status
- Who:
- Your DBA or platform administrator inspects the PostgreSQL server.
- How:
- Read the PostgreSQL server log entry for the failed login timestamp, query pg_hba_file_rules to identify the first matching authentication record and any non-null error fields, and check pg_authid to see whether the role has a stored scram-sha-256 or md5 hash.
- Result that matters:
- The exact server log reason, the first matching pg_hba.conf method, and whether the role password in pg_authid is null.
- If pg_authid shows a null password or an md5 hash against a scram-sha-256 rule, that confirms the server cannot validate the login until a SCRAM password is set.
- If an earlier pg_hba.conf record matches before the intended rule, that points to record ordering because pg_hba.conf has no fall-through or backup to subsequent lines.
- Evidence to keep:
- Save the server log line, the matching pg_hba_file_rules row number and method, and the hash type.
Do not switch pg_hba.conf records to trust on production networks to bypass 28P01; only the DBA should reload authentication rules.
Evidence: PostgreSQL 18 authentication problems · PostgreSQL 18 password authentication · PostgreSQL 18 the pg_hba.conf file
Still not solved
If the error persists, stop here. See what the technician must do and show you.
Virtual technician
Does 28P01 still appear after these checks?
This guided flow uses the exact code and your answers to choose a test, an expected result and the next branch.
Where this code applies
A code is meaningful only inside the right product and version context.
Primary scope
- System
- Software and digital services
- Brand
- PostgreSQL
- Product type
- Databases
Known code variants
- invalid_password
- PostgreSQL 28P01
- SQLSTATE 28P01
What it means
PostgreSQL Appendix A maps 28P01 to invalid_password in Class 28 Invalid Authorization Specification. Client authentication documentation explains that a failed password authentication message means the client reached the server, which requires the authorization method selected by the first matching record in pg_hba.conf with no fall-through to later lines. Password hashes live in pg_authid, and if no password was set for a user, the stored password is null and password authentication always fails. Code 28P01 alone does not prove the server is faulty or whether the password is wrong, null, or sent to the wrong host.
Warnings and stop conditions
- Mediumeditorial warning
Do not let applications retry a rejected password in a tight loop, and never paste database passwords or unredacted connection URIs into support tickets or logs.
Evidence: PostgreSQL 18 authentication problems · PostgreSQL 18 libpq password file
- Highsource verified
Never change pg_hba.conf to trust or send unencrypted password authentication over untrusted networks to silence 28P01; trust lets anyone who can reach the server log in as any PostgreSQL user without a password.
Evidence: PostgreSQL 18 password authentication · PostgreSQL 18 the pg_hba.conf file
Symptoms and causes
Probable causes · in order
- Client supplying a stale password or connecting to the wrong database hostCommon
After a credential rotation or deployment misconfiguration, the application reaches a PostgreSQL server that requires a password under pg_hba.conf, but the supplied secret does not match the hash stored for that LOGIN role.
Evidence: PostgreSQL client authentication · PostgreSQL 18 authentication problems · PostgreSQL 18 password authentication
- Unexpected password selected or ignored in .pgpass or pgpass.confPossible
When libpq reads .pgpass, %APPDATA%\postgresql\pgpass.conf, or PGPASSFILE, it uses the password from the first line matching hostname:port:database:username, and on Unix it ignores the file completely if permissions are less strict than 0600.
Evidence: PostgreSQL 18 libpq password file
- Database role has a null password in pg_authid or mismatched encryptionPossible
If no password has been set up for the requested user, the stored password in pg_authid is null so password authentication always fails, and an md5 hash cannot satisfy a pg_hba.conf rule that requires scram-sha-256.
Evidence: PostgreSQL 18 password authentication · PostgreSQL 18 the pg_hba.conf file
Sources and technical references
- 1
PostgreSQL 18 Appendix A: Error Codes
PostgreSQL Global Development Group · 2026 · official_doc
- 2
PostgreSQL client authentication
PostgreSQL Global Development Group · 2026 · official_doc
Was this entry useful?