Skip to main content
Kill -9 Club
Sign in

host-based authentication (pg_hba.conf)

Security

The file that decides, for each incoming connection, which method applies — by connection type, database, role and source address. On Ubuntu 24.04 that is /etc/postgresql/16/main/pg_hba.conf, and sudo -u postgres psql -c "show hba_file" tells you which one the server actually reads. It is walked top to bottom and the first matching line decides: rules do not combine, and if the chosen method fails the connection is refused without any later line being tried. So a line appended at the end, below a local all all peer, is never reached: the application keeps getting the same error while the file plainly contains the rule you wrote. Put yours above the general ones, run sudo systemctl reload postgresql, and read its line number back from pg_hba_file_rules.

Also written: pg_hba.conf, HBA, HBA rules

host-based authentication (pg_hba.conf) — definition | Kill -9 Club