FluentDBFluentDB
PostgreSQL errors

PostgreSQL: idle-in-transaction timeout

FATALSQLSTATE 25P03idle_in_transaction_session_timeout
FATAL: terminating connection due to idle-in-transaction timeout

Your session opened a transaction and then sat idle longer than idle_in_transaction_session_timeout, so Postgres closed it. Commit or roll back promptly, and do not hold a transaction open across slow work.

What this error means

An open transaction that sits idle holds locks and blocks vacuum. To prevent that, Postgres can close sessions that stay idle inside a transaction beyond a configured timeout, which raises this error on the client.

It usually means the app ran BEGIN, then did something slow such as a network call or waiting on user input, without committing.

How to fix it

01

A transaction is held open too long

Commit or roll back as soon as the work is done. Do not keep a transaction open across I/O or user think-time.

02

The timeout is too aggressive for a legitimate job

Raise it for that session only.

sql
SET idle_in_transaction_session_timeout = '60s';
03

An ORM leaves transactions open

Make sure the ORM commits or rolls back and returns connections to the pool promptly.

How to avoid it next time

  • Keep transactions short and do slow work outside them.
  • Add reconnect logic so a closed session recovers cleanly.

Frequently asked questions

Why does Postgres kill idle transactions?

An idle-in-transaction session holds locks and prevents vacuum from cleaning up, which harms the whole server. The timeout bounds that damage.

What sets this off with an ORM?

A transaction opened and left open across a slow operation. Make sure the ORM commits or rolls back promptly.

Stop struggling with SQL

Use FluentDB, the AI database client for macOS.