SQLSTATE 57P05 ERROR Class 57: Operator Intervention

idle_session_timeout Idle Session Timeout — SQLSTATE 57P05

The session was closed after exceeding idle_session_timeout.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Symptoms

The session was closed after exceeding idle_session_timeout.

  • The error is written to the server log and returned to the client carrying SQLSTATE 57P05.
  • Any driver (libpq, JDBC, psycopg, npgsql, pgx) surfaces this code in its error object so you can branch on it programmatically.
  • PL/pgSQL can trap it by name: EXCEPTION WHEN idle_session_timeout THEN.

Environment

Severity: ERROR  |  PostgreSQL versions: 12, 13, 14, 15, 16, 17

Commonly coincides with restarts, failover, maintenance, or network events; check server uptime and the log around the timestamp.

Root Cause

The connection sat idle (outside any transaction) longer than the configured limit and was reaped.

Diagnostic Queries

Recovery

Steps to resolve 57P05:

  1. Reconnect on demand.
  2. Tune idle_session_timeout and have the pool reap idle connections gracefully.

Reference: PostgreSQL error codes — Class 57 (Operator Intervention).

Was this helpful?