connection to server was lost

SQLSTATE 08006 condition connection_failure class 08 — Connection Exception severity FATAL
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 11 Jun 2026 · Reproduced live with the SQL on this page.

Symptoms

An established connection to the server was lost mid-operation. The driver reports SQLSTATE 08006 (connection_failure).

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

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”.