FluentDBFluentDB
PostgreSQL errors

PostgreSQL: no pg_hba.conf entry for host

FATALSQLSTATE 28000invalid_authorization_specification
FATAL: no pg_hba.conf entry for host "<ip>", user "<user>", database "<db>", no encryption

Postgres has no rule in pg_hba.conf that allows your combination of client IP, user, and database. Add a matching rule and reload the config, or connect with SSL if the existing rule requires an encrypted connection.

What this error means

pg_hba.conf is the host-based access control file. Every incoming connection is matched against its rules top to bottom, and if none matches the client's IP, user, and database, the connection is refused with this error.

The trailing 'no encryption' (or 'SSL off') means you connected without SSL and no plaintext rule matched. A hostssl rule would require an encrypted connection.

How to fix it

01

No rule covers your client

Add a rule for the client's IP range, user, and database, then reload the config.

text
# in pg_hba.conf
host   myapp   app_user   10.0.0.0/24   scram-sha-256

# then, in psql:
SELECT pg_reload_conf();
02

A rule exists but for a different user or database

Match the user and database exactly, or use the keyword all where appropriate.

03

The server requires SSL

If the matching rule is hostssl, connect with SSL so it applies.

text
postgresql://app_user@host:5432/myapp?sslmode=require

How to avoid it next time

  • Keep pg_hba rules scoped but correct, and reload the config after every edit.
  • Document which subnets your app connects from, so a new environment does not get locked out.

Frequently asked questions

How do I reload pg_hba.conf without a restart?

Run SELECT pg_reload_conf(); or pg_ctl reload. A full restart is not needed for pg_hba changes.

What does 'no encryption' mean in the message?

You connected without SSL and no plaintext host rule matched. Either add a host rule or connect with SSL to match a hostssl rule.

Stop struggling with SQL

Use FluentDB, the AI database client for macOS.