Terminate sessions idle outside any transaction (PG14+).
At a glance
| Property | Value |
|---|---|
| Parameter | idle_session_timeout |
| Category | Client Defaults |
| Default | 0 |
| Value type | time (ms/s/min) |
| Change scope | Per-session (SET) |
What it does
Closes connections idle (not in a transaction) longer than the limit (SQLSTATE 57P05). 0 disables.
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 idle_session_timeout; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'idle_session_timeout';.
Tuning guidance
Use to reap leaked connections from misbehaving clients. Do not set on connections managed by a pooler, which intentionally keeps idle connections warm.