Skip to content

pg_hba.conf checker

Free, no sign-up Runs in your browser

Paste pg_hba.conf and find trust rules, cleartext password and md5 methods, 0.0.0.0/0 ranges and host lines that allow unencrypted connections.

Checked as you type. Nothing you paste leaves this page.

The file is read in your browser. It is not uploaded.

Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.

How to use the pg_hba.conf checker

  1. Paste pg_hba.conf (SHOW hba_file; tells you where it is), drop it, or load the example.
  2. Replace trust and password with scram-sha-256, or peer for local sockets.
  3. Change host to hostssl for every range outside the machine.
  4. Reload with SELECT pg_reload_conf(); and check pg_hba_file_rules for errors.

About this tool

pg_hba.conf decides who may connect to PostgreSQL, from where, and how they prove who they are. The server reads it from the top and uses the first line that matches the connection type, database, user and client address. One generous line near the top therefore overrides every careful line below it.

This checker reads each record and reports the methods and ranges that weaken the server. trust accepts any user name with no credential. password sends the password itself over the connection. md5 uses a hash scheme that PostgreSQL 18 deprecates. It also reports rules for 0.0.0.0/0 or ::/0, host records that accept connections without TLS from other machines, and all/all rules on network ranges.

Severity depends on reach: trust on a local socket is a medium finding, trust for a network range is critical. The checker reads this one file, so it cannot see listen_addresses or your firewall, which also decide what is reachable. It does not replace a review of the roles themselves and what each one may do.

Sources

Questions

What does trust mean in pg_hba.conf?

That PostgreSQL does not check anything. Whoever can make a connection that matches the line can log in as any database user the line covers, including a superuser, without a password. It is only reasonable on a single-user machine, and even there peer authentication is the safer choice for local sockets.

What is the difference between md5 and scram-sha-256?

Both avoid sending the password in clear text, but MD5 hashes are fast to crack and the stored hash can be used to log in if it leaks. SCRAM-SHA-256 uses a salted, iterated hash and a challenge that proves both sides know the password. PostgreSQL has defaulted to SCRAM for new passwords since version 14, and version 18 deprecates MD5.

What is the difference between host and hostssl?

host matches TCP connections with or without TLS. hostssl matches only connections that use TLS, so a client that does not encrypt is refused instead of being served in clear text. Use hostssl for every address range outside the server itself.

Is 0.0.0.0/0 in pg_hba.conf always wrong?

It means any IPv4 address may try to authenticate. With hostssl and scram-sha-256 it is not an open door, but the database is then guarded by passwords alone. Narrow it to the networks that really connect, and keep the port behind a firewall.

Related tools