Diagnostic Queries
Symptoms
A session was terminated because it sat idle (not in a transaction) longer than idle_session_timeout. PostgreSQL raises SQLSTATE 57P05 (idle_session_timeout).
- An idle connection exceeded
idle_session_timeout. - PostgreSQL closed it to reclaim the slot.
- Distinct from idle-in-transaction timeout.
What the server log shows
FATAL: terminating connection due to idle-session timeout
Why PostgreSQL raises this — what the manual says
Section 19.11.1 Statement Behavior (idle_session_timeout):
“Terminate any session that has been idle (that is, waiting for a client query), but not within an open transaction, for longer than the specified amount of time.”
idle_session_timeout reclaims connections left idle (outside any transaction) beyond the limit, freeing connection slots. Sessions exceeding it are terminated with 57P05.
Common causes
- Connections left open and unused by the application.
- A pooler holding idle connections past the timeout.
- The timeout set lower than the pool’s idle period.
Relevant GUC parameters
| Parameter | Default | Effect |
|---|---|---|
idle_session_timeout |
0 | Terminate sessions idle (outside a transaction) beyond this; 0 disables. |
How to fix it
- Let the pooler reconnect; ensure it handles closed idle connections.
- Tune the timeout above the pool’s idle period if disconnects are disruptive.
- Reduce idle connections held by the application.
Related & next steps
Reference: PostgreSQL 18 Section 20.10 “Client Connection Defaults”.
Thanks — noted. This helps keep the database accurate.