<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/no-pg-hba-conf-entry-for-host-what-it-means-measured-81a5uad9x" -->

---
title: no pg_hba.conf entry for host: what it means, measured
description: The PostgreSQL error 'no pg_hba.conf entry for host' means the server found no matching rule in pg_hba.conf for the connection's address, user, database and...
canonical: https://daily.dev/posts/no-pg-hba-conf-entry-for-host-what-it-means-measured-81a5uad9x
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: no pg_hba.conf entry for host: what it means, measured | daily.dev
og:description: The PostgreSQL error 'no pg_hba.conf entry for host' means the server found no matching rule in pg_hba.conf for the connection's address, user, database and...
og:url: https://daily.dev/posts/no-pg-hba-conf-entry-for-host-what-it-means-measured-81a5uad9x
og:image: https://api.daily.dev/og/posts/81a5uaD9X.png
og:image:alt: no pg_hba.conf entry for host: what it means, measured
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# no pg_hba.conf entry for host: what it means, measured

**[Planet PostgreSQL](https://daily.dev/sources/planet-postgresql)** · 14 min read · 0 upvotes · 0 comments

## Summary

The PostgreSQL error 'no pg_hba.conf entry for host' means the server found no matching rule in pg_hba.conf for the connection's address, user, database and encryption mode, before any password check. Testing across Docker images for versions 12.22, 13.23, 14.24, 16.15, 17.11 and 18.6 shows the error text changed in version 14, from 'SSL on/off' to 'SSL encryption/no encryption'. In Docker, the address reported is the network gateway, not 127.0.0.1, since connections arrive through the published port. The 'all' database value does not cover physical replication, so pg_basebackup needs an explicit 'replication' line. Editing the file only takes effect after pg_reload_conf(), and a typo found at reload is ignored but prevents startup on restart.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://postgr.es/p/9Ad>

## Questions this post answers

### Why does my PostgreSQL connection fail with 'no pg_hba.conf entry for host 172.x.0.1' when I'm connecting to 127.0.0.1?

When PostgreSQL runs in Docker and you connect through the published port, the server sees the connection arriving from the container network's gateway address, not from 127.0.0.1. For example, on a 172.25.0.0/16 network the server reports the gateway 172.25.0.1. Fix it by adding a pg_hba.conf line scoped to that gateway address or your Docker subnet, such as 'host all all <gateway>/32 scram-sha-256', or use 'samenet'.

_Debugging Docker networking quirks like this gets easier with PostgreSQL references collected on daily.dev._

### Why does pg_basebackup fail with 'no pg_hba.conf entry for replication connection' even though psql connects fine with the same pg_hba.conf rule?

A pg_hba.conf line with 'all' in the database column does not cover physical replication connections; PostgreSQL requires a separate line with 'replication' as the database value. The official Docker image's default replication lines only allow 127.0.0.1/32 and ::1/128, so pg_basebackup from another host or container gets refused until you append a line like 'host replication all <range> scram-sha-256' and reload.

_Anyone setting up PostgreSQL replication can keep pg_hba.conf gotchas like this on their daily.dev radar._

### Do I need to restart PostgreSQL after changing pg_hba.conf, or is a reload enough?

A reload with select pg_reload_conf() is enough and is required for changes to take effect; pg_hba_file_rules shows the file's current contents even before a reload, which can be misleading. If the file has a typo, a reload logs the error and keeps running on the old rules, but a full restart with the same typo prevents the server from starting at all, exiting with 'could not load pg_hba.conf'.

_Developers tuning PostgreSQL configs track operational gotchas like this through daily.dev._

## Similar posts on daily.dev

- [All Your GUCs in a Row: listen\_addresses](https://daily.dev/posts/all-your-gucs-in-a-row-listen-addresses-ro7mqsnfu) · Planet PostgreSQL · 0 upvotes · 0 comments
- [My PostgreSQL database got nuked lol](https://daily.dev/posts/my-postgresql-database-got-nuked-lol-4uecfbpj6) · Lobsters · 0 upvotes · 0 comments
- [All Your GUCs in a Row: hba\_file](https://daily.dev/posts/all-your-gucs-in-a-row-hba-file-swywfe6vp) · Planet PostgreSQL · 0 upvotes · 0 comments
- [PgBouncer 1.26.0 released - Fixes three CVEs](https://daily.dev/posts/pgbouncer-1-26-0-released---fixes-three-cves-5uibkpxr4) · PostgreSQL · 0 upvotes · 0 comments

---

Tags: [#database](https://daily.dev/tags/database), [#docker](https://daily.dev/tags/docker), [#authentication](https://daily.dev/tags/authentication), [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/no-pg-hba-conf-entry-for-host-what-it-means-measured-81a5uad9x)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"no pg_hba.conf entry for host: what it means, measured","url":"https://daily.dev/posts/no-pg-hba-conf-entry-for-host-what-it-means-measured-81a5uad9x","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/no-pg-hba-conf-entry-for-host-what-it-means-measured-81a5uad9x"},"datePublished":"2026-10-28T00:03:09.345Z","dateModified":"2026-10-28T03:54:53.251Z","description":"The PostgreSQL error 'no pg_hba.conf entry for host' means the server found no matching rule in pg_hba.conf for the connection's address, user, database and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/fdeacaf2a945e58380479dc8aaeeee27?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/fdeacaf2a945e58380479dc8aaeeee27?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Planet PostgreSQL","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Planet PostgreSQL","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/planet-postgresql"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/no-pg-hba-conf-entry-for-host-what-it-means-measured-81a5uad9x","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"database,docker,authentication,postgresql","timeRequired":"PT14M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Planet PostgreSQL","item":"https://daily.dev/sources/planet-postgresql"},{"@type":"ListItem","position":3,"name":"no pg_hba.conf entry for host: what it means, measured"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/no-pg-hba-conf-entry-for-host-what-it-means-measured-81a5uad9x#faq","mainEntity":[{"@type":"Question","name":"Why does my PostgreSQL connection fail with 'no pg_hba.conf entry for host 172.x.0.1' when I'm connecting to 127.0.0.1?","acceptedAnswer":{"@type":"Answer","text":"When PostgreSQL runs in Docker and you connect through the published port, the server sees the connection arriving from the container network's gateway address, not from 127.0.0.1. For example, on a 172.25.0.0/16 network the server reports the gateway 172.25.0.1. Fix it by adding a pg_hba.conf line scoped to that gateway address or your Docker subnet, such as 'host all all \u003cgateway\u003e/32 scram-sha-256', or use 'samenet'. Debugging Docker networking quirks like this gets easier with PostgreSQL references collected on daily.dev."}},{"@type":"Question","name":"Why does pg_basebackup fail with 'no pg_hba.conf entry for replication connection' even though psql connects fine with the same pg_hba.conf rule?","acceptedAnswer":{"@type":"Answer","text":"A pg_hba.conf line with 'all' in the database column does not cover physical replication connections; PostgreSQL requires a separate line with 'replication' as the database value. The official Docker image's default replication lines only allow 127.0.0.1/32 and ::1/128, so pg_basebackup from another host or container gets refused until you append a line like 'host replication all \u003crange\u003e scram-sha-256' and reload. Anyone setting up PostgreSQL replication can keep pg_hba.conf gotchas like this on their daily.dev radar."}},{"@type":"Question","name":"Do I need to restart PostgreSQL after changing pg_hba.conf, or is a reload enough?","acceptedAnswer":{"@type":"Answer","text":"A reload with select pg_reload_conf() is enough and is required for changes to take effect; pg_hba_file_rules shows the file's current contents even before a reload, which can be misleading. If the file has a typo, a reload logs the error and keeps running on the old rules, but a full restart with the same typo prevents the server from starting at all, exiting with 'could not load pg_hba.conf'. Developers tuning PostgreSQL configs track operational gotchas like this through daily.dev."}}]}
```

