Specifies the amount of time that transmitted data may remain unacknowledged before the TCP connection is forcibly closed.
At a glance
| Property | Value |
|---|---|
| Parameter | tcp_user_timeout |
| Category | Connections and Authentication |
| Default | 0 |
| Value type | integer |
| Change scope | Per-session (SET) |
| Available in | PostgreSQL 12, 13, 14, 15, 16, 17, 18, 19 (added in 12) |
What it does
Specifies the amount of time that transmitted data may remain unacknowledged before the TCP connection is forcibly closed. If this value is specified without units, it is taken as milliseconds. A value of 0 (the default) selects the operating system’s default. This parameter is supported only on systems that support TCP_USER_TIMEOUT (which does not include Windows); on other systems, it must be zero. In sessions connected via a Unix-domain socket, this parameter is ignored and always reads as zero.
(Description quoted from the official PostgreSQL documentation.)
How to apply a change
Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.
Inspect the current value and source with SHOW tcp_user_timeout; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'tcp_user_timeout';.
Tuning guidance
Set it to control how long unacknowledged TCP data is retransmitted before the connection is dropped, tightening dead-peer detection on flaky networks; 0 uses the OS default.