idle session timeout
SQLSTATE 57P05 is raised when a session has been completely idle (no queries, not inside a transaction) for longer than idle_session_timeout. Postgres terminates the idle session to reclaim resources.
- 1An application connection has been open but completely idle for longer than idle_session_timeout
- 2Connection pool idle connections exceeding the session timeout
Application connection idle beyond idle_session_timeout.
-- In postgresql.conf: -- idle_session_timeout = 5min
expected output
FATAL: terminating connection due to idle-session timeout
Fix 1
Configure the connection pool to close connections before the timeout
WHEN When a connection pool holds idle connections too long.
Why this works
Set the pool maxIdleTime to less than idle_session_timeout. The pool will close and recreate connections before Postgres terminates them.
Fix 2
Increase idle_session_timeout or disable it for legitimate long-idle scenarios
WHEN When idle connections are expected (interactive sessions, monitoring tools).
SET idle_session_timeout = 0; -- disable for this session
Why this works
Setting to 0 disables the timeout for a specific session. Alternatively, increase the value in postgresql.conf for the whole server.
✕ Disable idle_session_timeout server-wide
Idle connections hold resources (memory, file descriptors). Use connection pooling instead.
idle_session_timeout parameter and SQLSTATE 57P05 introduced in Postgres 14.
Class 57 — Operator Intervention (Postgres-specific)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev