Specifies the amount of time after which a TCP keepalive message that has not been acknowledged by the client should be retransmitted.
At a glance
| Property | Value |
|---|---|
| Parameter | tcp_keepalives_interval |
| 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 after which a TCP keepalive message that has not been acknowledged by the client should be retransmitted. If this value is specified without units, it is taken as seconds. A value of 0 (the default) selects the operating system’s default. On Windows, setting a value of 0 will set this parameter to 1 second, since Windows does not provide a way to read the system default value. This parameter is supported only on systems that support TCP_KEEPINTVL or an equivalent socket option, and on 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_keepalives_interval; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'tcp_keepalives_interval';.
Tuning guidance
Time between TCP keepalive probes once started; lower it to detect dead peers faster at the cost of more probe traffic. Works with tcp_keepalives_count.