SQLSTATE 25P03 FATAL Class 25: Invalid Transaction State

idle_in_transaction_session_timeout terminating connection due to idle-in-transaction timeout — 25P03

PostgreSQL error “terminating connection due to idle-in-transaction timeout — 25P03” (SQLSTATE 25P03): what it means, common causes, and how to fix it.

PG 9.6, 10, 11, 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

Diagnostic Queries

Symptoms

A session was terminated because it sat idle inside an open transaction longer than idle_in_transaction_session_timeout. PostgreSQL raises SQLSTATE 25P03 (idle_in_transaction_session_timeout).

  • An open transaction was idle too long.
  • PostgreSQL terminated the connection to release locks/resources.
  • Common with apps that BEGIN and then stall.

What the server log shows

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

Why PostgreSQL raises this — what the manual says

Section 19.11.1 Statement Behavior (idle_in_transaction_session_timeout):

“Terminate any session that has been idle (that is, waiting for a client query) within an open transaction for longer than the specified amount of time.”

Idle-in-transaction sessions hold locks and pin old row versions, harming vacuum and concurrency. To protect the system, PostgreSQL terminates sessions idle beyond the timeout and reports 25P03.

Common causes

  • Application BEGIN followed by long inactivity.
  • A transaction left open awaiting user/external input.
  • Connection-pool bugs leaving transactions open.

Relevant GUC parameters

Parameter Default Effect
idle_in_transaction_session_timeout 0 Terminate sessions idle in a transaction beyond this; 0 disables.

How to fix it

  1. Commit/rollback promptly; avoid keeping transactions open during waits.
  2. Fix the application/pool to not leave idle transactions.
  3. Tune the timeout to match legitimate transaction durations.

Related & next steps

Reference: PostgreSQL 18 Section 20.10 “Client Connection Defaults”.

Was this helpful?