Diagnostic Queries
Symptoms
The client’s connection to the server was dropped unexpectedly mid-session. The driver reports SQLSTATE 08006 (connection_failure).
- The connection ended without a clean close.
- Often follows a backend crash, restart, or network drop.
- May indicate the server terminated the backend.
What the server log shows
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Why PostgreSQL raises this — what the manual says
As Section 32.1 Database Connection Control Functions explains:
This client-side message means the backend terminated the socket before completing the protocol exchange — commonly because the server process crashed, was shut down, or a connection limit or authentication step rejected the session mid-handshake.
When the TCP/socket connection breaks without a protocol-level close, the client reports 08006. This typically means the backend exited (crash, termination, or restart) or the network path failed.
Common causes
- A backend crash or server restart/failover.
- An admin terminating the session, or OOM killing the backend.
- Network instability, idle timeouts, or a firewall closing the socket.
How to fix it
- Reconnect and retry; make the application resilient to dropped connections.
- Check the server log for crashes/terminations around the time it dropped.
- Investigate network/firewall idle timeouts; use TCP keepalives or a pooler.
Related & next steps
Reference: PostgreSQL 18 Section 34.1 “Connection Control”.
Thanks — noted. This helps keep the database accurate.