SQLSTATE 08006 ERROR Class 08: Connection Exception

connection_failure could not receive data from server: Connection timed out — 08006

PostgreSQL error "could not receive data from server: Connection timed out" (SQLSTATE 08006): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

The client stopped receiving data from the server and the read timed out. The driver reports SQLSTATE 08006 (connection_failure).

  • A read on the connection timed out.
  • Common with network stalls or an unresponsive server.
  • May follow a long query or a dropped network path.

What the server log shows

could not receive data from server: Connection timed out

Why PostgreSQL raises this — what the manual says

Section 32.2 Connection Status Functions:

“Ordinarily, an OK status will remain so until PQfinish, but a communications failure might result in the status changing to CONNECTION_BAD prematurely.”

When the client waits for server data beyond the socket/keepalive timeout (because the server is unresponsive or the network path failed), the read times out and the driver reports 08006.

Common causes

  • Network instability or a severed path mid-query.
  • An unresponsive/overloaded server backend.
  • Firewall/NAT idle timeouts silently dropping the connection.

How to fix it

  1. Reconnect and retry; design for transient network failures.
  2. Tune TCP keepalives (tcp_keepalives_idle, etc.) to detect dead connections.
  3. Investigate server load/long queries and network reliability; use a pooler.

Related & next steps

Reference: PostgreSQL 18 Section 34.1 “Connection Control”.

Was this helpful?