Parameter · Connections and Authentication / TCP Settings
tcp_user_timeout
TCP user timeout. 0 means use the system default.
- Default:
0 - Type: integer (ms)
- Range: 0 … max (2147483647)
- Applies: Session (any user)
In plain words
When the server sends data (for example query results) to a client that has disappeared, the OS keeps retransmitting for a long time, up to around 15 minutes on Linux. tcp_user_timeout caps how long unacknowledged data may wait before the connection is closed.
For DBAs and operators
Sets the Linux socket option TCP_USER_TIMEOUT (milliseconds; not available on Windows; ignored for Unix sockets). It covers the case keepalives cannot: a connection that is not idle because the server is trying to send. Without it, a backend stuck writing to a vanished client sits in ClientWrite wait until the kernel gives up (tcp_retries2, typically ~15 min). With it, the write fails and the backend logs LOG: could not send data to client: Connection timed out and ends the session.
When combined with keepalives, Linux also applies it to the keepalive probes, so set it to at least idle + interval × count (in ms) to avoid cutting keepalive detection short. Very low values can kill healthy sessions on lossy networks. Typical: 30–120 s.
How to change it
Any user can change it for their session with SET.
See it in context
Related parameters
tcp_keepalives_idle tcp_keepalives_interval tcp_keepalives_count client_connection_check_interval