current transaction is aborted, commands ignored until end of transaction block

SQLSTATE 25P02 condition in_failed_sql_transaction class 25 — Invalid Transaction State severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 30 May 2025 · Reproduced live with the SQL on this page.

Symptoms

An earlier statement in the transaction failed, so the whole transaction is now in an aborted state. Every subsequent command is rejected with SQLSTATE 25P02 (in_failed_sql_transaction) until you roll back (or roll back to a savepoint).

What the server log shows

ERROR:  current transaction is aborted, commands ignored until end of transaction block

Why PostgreSQL raises this — what the manual says

Section 3.4 Transactions:

“Moreover, ROLLBACK TO is the only way to regain control of a transaction block that was put in aborted state by the system due to an error, short of rolling it back completely and starting again.”

When a statement errors inside a transaction, PostgreSQL marks the transaction aborted to preserve atomicity. It then refuses further work (25P02) until the application ends the block with ROLLBACK, or rewinds to a SAVEPOINT taken before the failure.

Common causes

How to fix it

  1. Issue ROLLBACK to end the transaction, then start fresh.
  2. Wrap fallible statements in SAVEPOINT/ROLLBACK TO SAVEPOINT to recover without losing the whole transaction.
  3. Find and fix the original error (it appears earlier in the log).

Related & next steps

Reference: PostgreSQL 18 Section 3.4 “Transactions”.