DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Client Connection Defaults / Statement Behavior

idle_session_timeout

Sets the maximum allowed idle time between queries, when not in a transaction. 0 disables the timeout.

  • Default: 0
  • Type: integer (ms)
  • Range: 0 … max (2147483647)
  • Applies: Session (any user)

In plain words

Closes connections that have been doing nothing, outside of a transaction, for longer than this time. It cleans up forgotten connections, but can surprise applications and connection pools that keep idle connections open on purpose.

For DBAs and operators

Added in PostgreSQL 14. Applies only to state idle (waiting for a query, no open transaction); idle-in-transaction is handled by idle_in_transaction_session_timeout. When it fires:

FATAL: terminating connection due to idle-session timeout

An idle session holds no locks (apart from session-level advisory locks) and does not block vacuum, so the benefit is only freeing a connection slot and backend memory. The risk is real: pools (PgBouncer, HikariCP, application pools) keep connections idle by design and may hand a killed connection to the application, producing "server closed the connection unexpectedly" errors. Either keep the pool's idle lifetime shorter than this timeout or set it only for interactive roles:

ALTER ROLE analyst SET idle_session_timeout = '30min';

How to change it

Any user can change it for their session with SET.

See it in context

Client backend Process model

Related parameters

idle_in_transaction_session_timeout transaction_timeout max_connections tcp_keepalives_idle

All Client Connection Defaults parameters