PostgreSQL 28000: invalid authorization specification
The server refused the login before checking a password: no pg_hba.conf rule matches, the role doesn't exist, or it can't log in.
- SQLSTATE
28000- Name
invalid_authorization_specification
What it means
28000 covers login failures other than a wrong password (28P01). The most common is no pg_hba.conf entry: the server's host-based authentication file has no line that matches this client's address, user, database and encryption. Others with this code are role "app" does not exist and role "app" is not permitted to log in (the role lacks the LOGIN attribute).
The message lists exactly what the server saw, which is what you need to match in pg_hba.conf. The last part says whether the connection was encrypted: a rule of type hostssl only matches SSL connections.
Common causes
- Connecting from a new IP address or network that no
pg_hba.confline covers. - The client connects without SSL but the only matching rule is
hostssl(or with SSL when the rule ishostnossl). - A rule that lists specific users or databases that don't include this one.
- The role doesn't exist on this server, or was created with
CREATE ROLE(which defaults toNOLOGIN) instead ofCREATE USER.
How to fix it
-
Add a
pg_hba.confline for the client, above any broaderrejectline, then reload. For examplehostssl shop app 10.0.0.0/24 scram-sha-256.SELECT pg_reload_conf(); SELECT line_number, type, database, user_name, address, auth_method, error FROM pg_hba_file_rules;
-
Allow the role to log in, or create it.
ALTER ROLE app WITH LOGIN; CREATE ROLE app WITH LOGIN PASSWORD 'strong-password';
-
Make sure the server listens on the network at all (
listen_addresses), and that the client uses SSL if the rule needs it, for examplesslmode=require.
Related errors
28P01password authentication failed08001unable to establish connection3D000database does not exist42501permission denied1130MySQL: Host is not allowed to connect18456SQL Server: Login failed for user
The code and message text are from the PostgreSQL documentation, Appendix A: PostgreSQL Error Codes. Browse the full PostgreSQL error list or search every database error.
Work on PostgreSQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for PostgreSQL and the other databases you use.