SQLSTATE 08006 FATAL Class 08: Connection Exception

connection_failure connection to server was lost — 08006

PostgreSQL error “connection to server was lost — 08006” (SQLSTATE 08006): what it means, common causes, and how to fix it.

PG 9.6, 10, 11, 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

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

  1. Reconnect and retry; make the app resilient to dropped connections.
  2. Check the server log for crashes/terminations.
  3. Investigate network reliability; use keepalives or a pooler.

Related & next steps

Reference: PostgreSQL 18 Section 34.1 “Connection Control”.

Was this helpful?