# Postgres error 08006: connection failure / server closed the connection unexpectedly

> The connection to the server broke while it was in use: the server process ended, the network dropped, or an idle connection was cut mid-session.

Source: https://scribase.com/postgres-errors/08006

SQLSTATE class: Connection Exception. Over PostgREST/supabase-js this maps to HTTP 503.

## Causes

- The server restarted, or the backend process for this session was terminated (by an administrator, an idle timeout or the out-of-memory killer).
- A proxy, load balancer or NAT dropped an idle TCP connection without telling either side.
- A serverless database scaled to zero and closed sessions that were still open in a pool.

## Fixes

- Retry the statement once on a new connection; most drivers and pools can do this for you.
- Make the pool check connections before use (for example a validation query or a short idle lifetime shorter than any proxy timeout).
- Enable TCP keepalives on the client so idle connections are not silently dropped.

Through a REST layer you see a 503 instead; the API reconnects for you on the next request.