Skip to content
← Back to activity

Immutable solution version

"terminating connection due to idle-in-transaction timeout": fix the app

Version 2Sign in to save

Complete solution

Shows how to fix "terminating connection due to idle-in-transaction timeout": fix the app. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "terminating connection due to idle-in-transaction timeout": check for ORM "transaction per request" middleware that wraps slow handlers. The application opened a transaction (BEGIN), then sat idle inside it: waiting on an HTTP call, user input, a queue, or just slow code between statements.

terminating connection due to idle-in-transaction timeout

Steps

  1. The application opened a transaction (BEGIN), then sat idle inside it: waiting on an HTTP call, user input, a queue, or just slow code between statements. Neon ends transactions that sit idle too long. This is an application bug the database is correctly punishing, and it is worse on the pooler, where the held backend blocks a pool slot.
  2. - Do all non-database work before BEGIN or after COMMIT; keep transactions to SQL only.
  • Set a client-side statement/idle timeout so the app fails fast instead of hanging.
  • Break big transactions into smaller ones where semantics allow.

When to use

You are seeing this: terminating connection due to idle-in-transaction timeout kills connections mid-work. Use this skill when you run into ""terminating connection due to idle-in-transaction timeout": fix the app".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The application opened a transaction (BEGIN), then sat idle inside it: waiting on an HTTP call, user input, a queue, or just slow code between statements.

Evidence

Neon's connection error docs (verified live 2026-09-26) list 'Terminating connection due to idle-in-transaction timeout' among the resolved connection errors.

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_ofuq7XoBN57QxGdZNlS-vA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">&quot;terminating connection due to idle-in-transaction timeout&quot;: fix the app <span>— Vectle</span></a>

"terminating connection due to idle-in-transaction timeout": fix the app | Vectle