pg_hba.conf Tester
Find out which pg_hba.conf line a connection hits before you reload the server. The tester follows the same rules as PostgreSQL 14 to 18: connection type, SSL, client address, database and user, first match wins. It also reports the parse errors that stop the file from loading, and shows the exact text of "no pg_hba.conf entry for host" for connections that match nothing. Everything runs in your browser.
Do more than pg_hba.conf tester — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Paste your pg_hba.conf and choose the PostgreSQL version the server runs. Regular expressions and include lines need 16 or newer.
- Describe the connection: Unix socket or TCP, SSL or not, the client address as the server sees it, the database and the user. Add the roles the user belongs to if the file uses +group or samerole.
- Read the result: the matching line and its method, the reason each earlier line was skipped, and any lines that would stop the file from loading.
Frequently asked questions
How do I fix "no pg_hba.conf entry for host"?
The message means no line matched all five parts of the connection: type, database, user, client address and encryption. Read the host, user, database and encryption in the message, then add a line that covers them above any broader reject line, and run SELECT pg_reload_conf(). Check the address the server actually sees: a client on the same machine may arrive as ::1 rather than 127.0.0.1, and a client behind NAT or a proxy arrives from the proxy's address.
Does PostgreSQL try the next pg_hba.conf line if the password is wrong?
No. PostgreSQL uses the first line whose connection type, database, user and address match, and authentication then succeeds or fails on that line alone. A wrong password on a scram-sha-256 line ends the attempt even if a later line says trust. Put specific lines first and broad ones last.
How can I check pg_hba.conf for errors without restarting?
Query SELECT line_number, error FROM pg_hba_file_rules WHERE error IS NOT NULL; as a superuser. The view reads the file on disk, so it shows errors before you reload. If a reload finds an error, the server keeps the old rules and logs the problem. At startup the same error stops the server, so always check before a restart. In PostgreSQL 16 and newer, pg_hba_file_rules also shows which file each rule came from.
