DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Connections and Authentication / TCP Settings

tcp_keepalives_idle

Time between issuing TCP keepalives. 0 means use the system default.

  • Default: 0
  • Type: integer (s)
  • Range: 0 … max (2147483647)
  • Applies: Session (any user)

In plain words

If a client machine crashes or a firewall silently drops a connection, the server may not notice for hours. TCP keepalives are small probes the OS sends on an idle connection. This setting says how long the connection must be silent before the first probe.

0 means the operating-system default, which on Linux is 2 hours.

For DBAs and operators

Sets the socket option TCP_KEEPIDLE (seconds) on each client connection; it only applies to TCP sessions (it reads as 0 on Unix-socket sessions). Dead-peer detection time is roughly idle + interval × count; with Linux defaults (7200 s, 75 s, 9) that is about 2 h 11 min. When the probes fail, the backend's next read fails and it exits with LOG: could not receive data from client: Connection timed out, releasing its locks and its connection slot.

Why it matters in support tickets: sessions left idle in transaction by a vanished client keep locks and hold back the xmin horizon (vacuum cannot clean). Stateful firewalls and cloud load balancers often drop idle flows after some minutes without telling either side; keepalives shorter than that keep the flow alive. A typical server setting: tcp_keepalives_idle = 60, tcp_keepalives_interval = 10, tcp_keepalives_count = 6. Clients have matching libpq options (keepalives_idle …). Check per session with SHOW tcp_keepalives_idle from that session.

How to change it

Any user can change it for their session with SET.

See it in context

Client backend Wire protocol

Related parameters

tcp_keepalives_interval tcp_keepalives_count tcp_user_timeout client_connection_check_interval idle_in_transaction_session_timeout

All Connections and Authentication parameters