{"Entry":{"collection":"guc","key":"tcp_keepalives_count","name":"tcp_keepalives_count","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Connections and Authentication / TCP Settings","category_zh":"","changed_in":["14","15","16","18"],"changes":[{"documentation_changed":false,"fields":{},"from":"8.0","status":"added","to":"8.1"},{"documentation_changed":true,"fields":{},"from":"8.1","status":"changed","to":"8.2"},{"documentation_changed":true,"fields":{},"from":"8.2","status":"changed","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"},{"documentation_changed":true,"fields":{},"from":"9.1","status":"changed","to":"9.2"},{"documentation_changed":true,"fields":{},"from":"9.3","status":"changed","to":"9.4"},{"documentation_changed":true,"fields":{},"from":"9.6","status":"changed","to":"10"},{"documentation_changed":true,"fields":{},"from":"11","status":"changed","to":"12"},{"documentation_changed":false,"fields":{"category":{"from":"Client Connection Defaults / Other Defaults","to":"Connections and Authentication / Connection Settings"}},"from":"13","status":"changed","to":"14"},{"documentation_changed":false,"fields":{"extra_desc":{"from":"This controls the number of consecutive keepalive retransmits that can be lost before a connection is considered dead. A value of 0 uses the system default.","to":"Number of consecutive keepalive retransmits that can be lost before a connection is considered dead. A value of 0 uses the system default."}},"from":"14","status":"changed","to":"15"},{"documentation_changed":true,"fields":{"category":{"from":"Connections and Authentication / Connection Settings","to":"Connections and Authentication / TCP Settings"}},"from":"15","status":"changed","to":"16"},{"documentation_changed":false,"fields":{"extra_desc":{"from":"Number of consecutive keepalive retransmits that can be lost before a connection is considered dead. A value of 0 uses the system default.","to":"Number of consecutive keepalive retransmits that can be lost before a connection is considered dead. 0 means use the system default."}},"from":"17","status":"changed","to":"18"}],"content_hash":"d1a70159c5a2e124853f242a1b7bd6745e446df229b3c84e4bfd5604016324e1","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"0"}],"editorial":{"advice":{"olap":"Long analytical connections need keepalive timing shorter than intervening network idle expiry but not so aggressive that transient loss aborts healthy jobs.","oltp":"Choose tcp_keepalives_count with the other keepalive controls so total failure-detection time fits load-balancer, failover, and retry budgets. Confirm the operating system implements the requested socket option.","small":"Use operating-system defaults unless a measured network failure mode requires an override; tune the complete idle/interval/count tuple, not tcp_keepalives_count alone."},"mechanism":["tcp_keepalives_count sets the maximum number of TCP keepalive retransmits. Number of consecutive keepalive retransmits that can be lost before a connection is considered dead. 0 means use the system default. Together with idle and interval, it determines how many unanswered probes precede failure; zero selects the operating-system default where supported.","tcp_keepalives_count is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.","The effective failure window is derived from tcp_keepalives_idle, tcp_keepalives_interval, and tcp_keepalives_count, subject to operating-system support and any shorter network-device timeout."],"pitfalls":["Changing tcp_keepalives_count in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.","Tuning one keepalive component without calculating the full idle-plus-retransmit failure window.","Assuming PostgreSQL's requested value overrides unsupported platforms or a shorter firewall and load-balancer idle policy.","Assuming zero means no probes when it actually selects the operating-system default."],"references":[{"title":"PostgreSQL 19 Beta 4: tcp_keepalives_count","url":"https://www.postgresql.org/docs/19/runtime-config-connection.html#GUC-TCP-KEEPALIVES-COUNT"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["tcp_keepalives_idle","tcp_keepalives_interval","tcp_user_timeout","client_connection_check_interval","authentication_timeout"],"summary":"tcp_keepalives_count is the PostgreSQL setting that defines the maximum number of TCP keepalive retransmits."},"enumvals":[],"first_version":"8.1","group":"Connections and Authentication","group_slug":"connection","imported_at":"2026-09-27T17:57:32.136392+08:00","intro_commit":{},"key":"tcp_keepalives_count","last_version":"20","max_val":"","min_val":"","name":"tcp_keepalives_count","position":406,"present_in":["8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"Specifies the number of TCP keepalive messages that can be lost before the server's connection to the client is considered dead.","short_desc_zh":"","source_rev":"english-manuals:ae88c4bc353b47615299692838127c225d1eb09b34b57a4d2cc91c026a260524","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"tcp_keepalives_count","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"tcp_keepalives_count","SourceRevision":"english-manuals:ae88c4bc353b47615299692838127c225d1eb09b34b57a4d2cc91c026a260524","Facts":{"boot_val":"0","category":"Connections and Authentication / TCP Settings","context":"user","description":"Specifies the number of TCP keepalive messages that can be lost before the server's connection to the client is considered dead. A value of 0 (the default) selects the operating system's default. This parameter is supported only on systems that support TCP_KEEPCNT or an equivalent socket option (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.","doc":{"anchor":"GUC-TCP-KEEPALIVES-COUNT","file":"runtime-config-connection.html","lang":"en","sha256":"567ba928f3e4c4783f548dc8a54f1e748f02bbe163924605f2132eb5b0da440d","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"Number of consecutive keepalive retransmits that can be lost before a connection is considered dead. 0 means use the system default.","lang":"en","max_val":"2147483647","metadata_version":"18","min_val":"0","name":"tcp_keepalives_count","short_desc":"Maximum number of TCP keepalive retransmits.","source":"pg-settings-source-snapshot","unit":null,"vartype":"integer"},"ManualEvidence":{"doc":{"anchor":"GUC-TCP-KEEPALIVES-COUNT","file":"runtime-config-connection.html","lang":"en","sha256":"567ba928f3e4c4783f548dc8a54f1e748f02bbe163924605f2132eb5b0da440d","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"tcp_keepalives_count","SourceDatabase":"center","Version":"18","Locale":"en","Title":"tcp_keepalives_count","Summary":"Specifies the number of TCP keepalive messages that can be lost before the server's connection to the client is considered dead. A value of 0 (the default) selects the operating system's default. This parameter is supported only on systems that support TCP_KEEPCNT or an equivalent socket option (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.","BodyHTML":"\u003cp\u003eSpecifies the number of TCP keepalive messages that can be lost before the server\u0026#39;s connection to the client is considered dead. A value of 0 (the default) selects the operating system\u0026#39;s default. This parameter is supported only on systems that support TCP_KEEPCNT or an equivalent socket option (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.\u003c/p\u003e","SourceRevision":"english-manuals:ae88c4bc353b47615299692838127c225d1eb09b34b57a4d2cc91c026a260524","ContentHash":"0d8629ccea30c6caa1a9f4239d98ac4408c6eb742a0835c2769c55f8d5d91ef4","Payload":{"description":"Specifies the number of TCP keepalive messages that can be lost before the server's connection to the client is considered dead. A value of 0 (the default) selects the operating system's default. This parameter is supported only on systems that support TCP_KEEPCNT or an equivalent socket option (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."}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
