Skip to content
Commitpedia
Log in Join & edit

Fix: FATAL: no pg_hba.conf entry for host

The server received the connection but no pg_hba.conf rule matches this client address, user, database and SSL mode. Add or correct a rule and reload the configuration.

Not checked by a trusted editor yet Last edited Outdated?

Edit history of Fix: FATAL: no pg_hba.conf entry for host: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
2 min

The PostgreSQL documentation shows the error in this form:

FATAL:  no pg_hba.conf entry for host "123.123.123.123", user "andym", database "testdb"

Recent server versions append the connection’s encryption state at the end, for example , no encryption or an SSL note. Read every part of the message: it tells you exactly which combination of client address, user, database and encryption found no matching rule.

This is not a password problem. The client reached the server and the server is running, but pg_hba.conf has no line for this connection, so it is refused before any password is asked for.

Causes, most likely first

  1. No rule for the client’s network. The default file usually allows only local socket and loopback (127.0.0.1/32, ::1/128) connections. The client’s address is shown in the message; behind NAT, a proxy or Docker it may not be the address you expected.
  2. SSL mismatch. A hostssl rule matches only encrypted connections and hostnossl only unencrypted ones. If the message says no encryption and you only have hostssl lines, the client must connect with SSL (for example sslmode=require) or you need a host rule.
  3. Database or user does not match. The rule names a different database or role, or uses +group and the user is not a member.
  4. Replication connection. Standbys and pg_basebackup need a rule with the special database name replication; all does not match replication connections.
  5. You edited a file the server does not read, or did not reload after editing.

Fix it step by step

  1. Find the file the server uses: sudo -u postgres psql -c 'SHOW hba_file;'.
  2. Add a rule as narrow as possible: the specific database, user and client network, with scram-sha-256.
  3. Make sure no earlier line already matches this connection with a different result (for example a reject rule).
  4. Check for parse errors, then reload. A restart is not needed.
  5. Connect again from the client.
# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    appdb           appuser         10.0.0.0/24             scram-sha-256
hostssl appdb           appuser         192.0.2.0/24            scram-sha-256
host    replication     replicator      10.0.0.12/32            scram-sha-256
SELECT line_number, type, database, user_name, address, auth_method, error
FROM pg_hba_file_rules;

SELECT pg_reload_conf();

pg_hba_file_rules shows the file as currently saved on disk, so you can spot a typo (a non-empty error column) before reloading.

Related checks

  • If the client gets Connection refused or a timeout instead, the server is not listening on that address or a firewall blocks port 5432; check listen_addresses in postgresql.conf (restart required) and the firewall.
  • Do not “fix” this with host all all 0.0.0.0/0 trust. That allows anyone who can reach the port to log in as any user without a password.
  • On managed or containerized PostgreSQL, the rules may be generated by the platform; change them through its configuration rather than by editing the file.

Official documentation

Did this work for you?

No votes yet. Be the first.

If it did not work, the report form below tells the editors what went wrong.

See also

  • 0198 Install PostgreSQL and connect with psql on Debian, Ubuntu and RHEL Install the PostgreSQL server from your distribution or the official PGDG repositories, start it, and open your first psql session as the… Beginner · Step by step · Linux Article Install & connect 15 Oct 2026
  • 0199 psql meta-commands cheat sheet The backslash commands you use every day in psql: connecting, listing databases, tables and roles, describing objects, timing queries, expanded output and… Beginner · Cheat sheet · Any system Article Install & connect · Roles & administration 15 Oct 2026
  • 0200 PostgreSQL roles, privileges and default privileges Create login and group roles, grant access to databases, schemas and tables, and use ALTER DEFAULT PRIVILEGES so tables created later get… Intermediate · Step by step · Linux Article Roles & administration · Security & access 15 Oct 2026
  • 0201 pg_hba.conf and PostgreSQL authentication methods pg_hba.conf decides who may connect from where and how they must prove who they are. Rules are checked top to bottom and… Intermediate · Explains an idea · Linux Article Install & connect · Security & access 15 Oct 2026
  • 0209 Fix: FATAL: password authentication failed for user PostgreSQL reached the server and found a matching pg_hba.conf rule, but the password check failed. Usually a wrong password, a role without… Intermediate · Fixes an error · Any system Article Roles & administration · Security & access 15 Oct 2026
  • 0211 Fix: psql connection to server on socket /var/run/postgresql/.s.PGSQL.5432 failed psql tried the local Unix socket and found nothing there. The server is not running, listens on another port, or uses a… Beginner · Fixes an error · Linux Article Install & connect 15 Oct 2026

Repos in the wild

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Commitpedia +3,122 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?