Diagnostic Queries
Symptoms
A standby/replica could not connect to its primary server to stream WAL. The startup/walreceiver process reports SQLSTATE 08006 (connection_failure).
- The replica’s walreceiver cannot reach the primary.
- Replication stalls and the replica falls behind.
- Often a primary down, wrong primary_conninfo, or firewall.
What the server log shows
FATAL: could not connect to the primary server: connection to server at "10.0.0.5", port 5432 failed: Connection refused
Why PostgreSQL raises this — what the manual says
Section 26.2 Log-Shipping Standby Servers (Streaming Replication):
“If you want to use streaming replication, fill in primary_conninfo with a libpq connection string, including the host name (or IP address) and any additional details needed to connect to the primary server.”
A streaming replica opens a replication connection to the primary defined by primary_conninfo. If that connection is refused (primary down, wrong host/port, firewall), the walreceiver cannot stream WAL and reports 08006.
Common causes
- The primary server is down or not accepting connections.
- Wrong host/port in
primary_conninfo. - Firewall/network blocking the replication port.
How to fix it
- Verify the primary is up and listening on the replication port.
- Check
primary_conninfohost/port and credentials. - Open firewalls and confirm the replica can reach the primary.
Related & next steps
Reference: PostgreSQL 18 Section 27.2 “Log-Shipping Standby”.
Thanks — noted. This helps keep the database accurate.