# tcp_user_timeout

> tcp_user_timeout is the PostgreSQL setting that defines the TCP user timeout.
---

> [!NOTE]
> **Fact — official short description:** “TCP user timeout.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `user` | Settable by an ordinary user |
| Unit | `ms` | Raw unit |
| Range | `0` – `2147483647` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Connections and Authentication / TCP Settings | Upstream classification |
| Latest boot value | `0` | 0 ms |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG12 |
| Present in | PG12–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`249d64999615`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=249d64999615802752940e017ee5166e726bc7cd) — Add support TCP user timeout in libpq and the backend server |
| Commit date | 2019-04-06 |
| Discussion | [thread 1](https://postgr.es/m/EDA4195584F5064680D8130B1CA91C45367328@G01JPEXMBYT04) |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG12–19 Beta 3 | `0` | `ms` | 0 ms |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

tcp_user_timeout sets the TCP user timeout. 0 means use the system default. Where supported, it bounds how long transmitted data may remain unacknowledged before TCP closes the connection; it is distinct from keepalive probing of an idle connection.

tcp_user_timeout 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.

Timeouts overlap: the first applicable deadline wins, while client, pooler, TCP, and server cancellation behavior determines whether work is retried, canceled, or the session is closed.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Set tcp_user_timeout from the maximum acceptable unacknowledged-data stall, below the service failover budget and with client retry behavior tested. |
| OLAP | Allow for temporary congestion during large result transfer, but keep the value below the point where an unreachable peer wastes a worker for the rest of the job window. |
| Small nodes | Use the operating-system default unless measured half-open connections require a bound; confirm platform support before relying on it. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | Unmodified | — | — |
| OLAP | Unmodified | — | — |
| CRIT | Unmodified | — | — |
| TINY | Unmodified | — | — |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG12–19 Beta 3 unmodified; OLAP: PG12–19 Beta 3 unmodified; CRIT: PG12–19 Beta 3 unmodified; TINY: PG12–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- Changing tcp_user_timeout in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
- Forgetting that zero usually disables the timeout or delegates behavior to the operating system.
- Setting overlapping deadlines without deciding which layer owns retries, cancellation, and connection disposal.
- Confusing unacknowledged-data timeout with keepalive detection for an otherwise idle socket.

## Related parameters {#related-parameters}

[`tcp_keepalives_idle`](/parameters/tcp-keepalives-idle/) · [`tcp_keepalives_interval`](/parameters/tcp-keepalives-interval/) · [`tcp_keepalives_count`](/parameters/tcp-keepalives-count/) · [`client_connection_check_interval`](/parameters/client-connection-check-interval/) · [`authentication_timeout`](/parameters/authentication-timeout/)

## References {#references}

- [PostgreSQL 19 Beta 3 — tcp_user_timeout](https://www.postgresql.org/docs/19/runtime-config-connection.html#GUC-TCP-USER-TIMEOUT)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
