DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Client Connection Defaults / Statement Behavior

idle_in_transaction_session_timeout

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

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

In plain words

"Idle in transaction" means a session ran BEGIN (and maybe some queries), then stopped sending anything without committing. It keeps its locks and stops vacuum from cleaning up. This timeout terminates such sessions after the given time.

For DBAs and operators

Measured from the moment the backend becomes idle inside a transaction block (state idle in transaction or idle in transaction (aborted) in pg_stat_activity). When it fires, the whole session is terminated, not just the transaction:

FATAL: terminating connection due to idle-in-transaction timeout

The open transaction rolls back, its locks are released, and its snapshot no longer holds back the xmin horizon, so vacuum can remove dead rows again. This protects against application bugs (forgotten commit, an exception path without rollback, a user leaving a psql BEGIN open).

Find offenders first:

SELECT pid, usename, state, now() - state_change AS idle_for, query
FROM pg_stat_activity
WHERE state LIKE 'idle in transaction%' ORDER BY idle_for DESC;

Typical values are 1–10 minutes globally, shorter per application role. Behind a connection pooler the terminated server connection is lost too, so the application typically sees an error on its next statement. See also transaction_timeout (PG 17+), which limits total transaction time instead of idle time.

How to change it

Any user can change it for their session with SET.

See it in context

VACUUM Snapshots and visibility Locking and deadlocks Process model Client backend MVCC: row versions

Related parameters

idle_session_timeout transaction_timeout statement_timeout lock_timeout

All Client Connection Defaults parameters