dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Error Library/postgresql-no-pg-hba-conf-entry
PostgreSQL
PostgreSQL 14–18Network & Authentication
7 min read
FATAL: no pg_hba.conf entry for host, user, database, SSL off / no encryption (SQLSTATE 28000)

PostgreSQL "no pg_hba.conf entry for host" — Rule Exists, Why Rejected?

Diagnosing pg_hba.conf rejection: understanding first-match rule evaluation, inspecting pg_hba_file_rules, host vs hostssl TLS mismatches, and pg_reload_conf.

Reviewed by:Principal Database Reliability Architect
Tested Versions: PostgreSQL 18.6 & 17.11 (Alpine Linux / Ubuntu 24.04 LTS / Docker 29.7) | Tarihsel: PostgreSQL 14, 15, 16

Operational Verification & Reliability Metadata

Last Technical Review: 30 Ekim 2026
Tested VersionsPostgreSQL 18.6 & 17.11 (Alpine / Ubuntu 24.04, Docker 29.7) | Tarihsel: 14.10, 15.6, 16.4
Required PrivilegesSUPERUSER (for pg_hba_file_rules and pg_reload_conf) or OS filesystem access
Risk Assessment
HighBroadly configuring 0.0.0.0/0 trust or md5 exposes the cluster to brute force or unauthenticated intrusion
Expected OutputTarget client IP correctly matching top-precedence rule in pg_hba_file_rules and zero-downtime pg_reload_conf()
Rollback Procedure:Prune broad catch-all rules and enforce narrow CIDR subnets with modern scram-sha-256
PostgreSQL Docs: The pg_hba.conf File & Precedence
First 60 Seconds Emergency Protocol:

The error string is a symptom, not the root cause. Do not restart the server blindly. Run the diagnostic queries below to pinpoint the actual failure mode.

▸Symptom

plaintext
FATAL: no pg_hba.conf entry for host "10.0.2.15", user "app", database "app", no encryption FATAL: no pg_hba.conf entry for host "10.0.2.15", user "app", database "app", SSL off

SQLSTATE code: 28000 (invalid_authorization_specification).

The terminal snippet (SSL off, no encryption, or SSL on) identifies whether the connecting client negotiated TLS encryption.

Administrators frequently ask: *"I already appended the client IP to pg_hba.conf, why is it still getting rejected?"*

IMPORTANT
The Golden Rule: pg_hba.conf Enforces FIRST MATCH Precedence! Unlike modern firewall rule sets, pg_hba.conf does not evaluate rules based on specificity (most specific CIDR mask does NOT take priority). PostgreSQL scans the configuration file sequentially from top to bottom and applies the very FIRST record that matches. If a broad catch-all record exists higher up in the file (e.g. host all all 0.0.0.0/0 reject or an overly restrictive hostssl entry), any fine-grained rule placed below it is completely unreachable.

▸Diagnostic Step: Querying `pg_hba_file_rules`

Rather than parsing configuration files manually on disk, inspect PostgreSQL's parsed rule evaluation table:

sql
SELECT line_number, type, database, user_name, address, netmask, auth_method, error FROM pg_hba_file_rules ORDER BY line_number;

Benefits of inspecting pg_hba_file_rules:

  1. 1Reveals the exact sequential evaluation order evaluated by the postmaster.
  2. 2The `error` column flags syntax errors that cause PostgreSQL to silently bypass malformed lines.
  3. 3Confirm the actual configuration file path being consumed:
sql
SHOW hba_file; SHOW listen_addresses; SHOW port;

Editing the wrong pg_hba.conf across multiple cluster installations is a common mistake.


▸Disambiguating `host`, `hostssl`, and `hostnossl`

  • •`host`: Matches both TLS-encrypted and unencrypted TCP connections.
  • •`hostssl`: Matches only TLS/SSL connections. If the client connects with sslmode=disable, this rule will not match, triggering FATAL: no pg_hba.conf entry ... SSL off.
  • •`hostnossl`: Matches only unencrypted connections; secure clients will not match.

▸Step-by-Step Production Resolution

1. Place the Rule Early with Narrow Subnet Definitions

Insert a specific rule near the top of pg_hba.conf:

plaintext
# TYPE DATABASE USER ADDRESS METHOD hostssl app app 10.0.2.0/24 scram-sha-256

2. Reload Configuration with Zero Downtime

Modifying pg_hba.conf never requires a cluster restart. To apply rules instantaneously without disconnecting active client sessions:

sql
SELECT pg_reload_conf();

Or via the operating system shell:

bash
systemctl reload postgresql

3. Confirm Network Binding in postgresql.conf

Ensure the daemon listens on network interfaces:

ini
listen_addresses = '*'

▸Related Error Guides & Hub Links

Other Database Error Triage Playbooks

Other battle-tested diagnostic guides for high-severity database errors.

All Errors (50)