Diagnostic Queries
Symptoms
An established connection to the server was lost mid-operation. The driver reports SQLSTATE 08006 (connection_failure).
- The connection dropped during a query or transaction.
- Often a backend crash/termination or network drop.
- The session must be re-established.
What the server log shows
ERROR: connection to server was lost
Why PostgreSQL raises this — what the manual says
As Section 32.1 Database Connection Control Functions explains:
An already-established connection was dropped before the current command finished — typically due to a backend crash, an administrator terminating the session, a server restart, or a network interruption between client and server.
When the socket to the backend breaks while work is in flight, the client cannot complete the request and reports 08006. This usually means the backend exited or the network path failed.
Common causes
- A backend crash, restart, or admin termination.
- Out-of-memory killing the backend.
- Network instability or idle-timeout drops.
How to fix it
- Reconnect and retry; make the app resilient to dropped connections.
- Check the server log for crashes/terminations.
- Investigate network reliability; use keepalives or a pooler.
Related & next steps
Reference: PostgreSQL 18 Section 34.1 “Connection Control”.
Thanks — noted. This helps keep the database accurate.