SQLSTATE 25P02 ERROR Class 25: Invalid Transaction State

in_failed_sql_transaction current transaction is aborted, commands ignored until end of transaction block — 25P02

PostgreSQL error “current transaction is aborted, commands ignored until end of transaction block — 25P02” (SQLSTATE 25P02): 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 command was issued in a transaction that already failed; PostgreSQL ignores all commands until the transaction is ended. It raises SQLSTATE 25P02 (in_failed_sql_transaction).

  • An earlier error aborted the transaction.
  • All subsequent commands are rejected until rollback.
  • Common when error handling doesn’t roll back.

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:

“The essential point of a transaction is that it bundles multiple steps into a single, all-or-nothing operation.”

Once a statement errors inside a transaction, PostgreSQL marks the whole transaction aborted. To prevent partial/inconsistent work, it rejects every further command with 25P02 until you ROLLBACK (optionally to a savepoint).

Common causes

  • A prior statement in the transaction raised an error.
  • Error handling that continues issuing commands without rolling back.
  • No savepoint to recover to after a failed statement.

How to fix it

  1. Issue ROLLBACK to end the transaction, then start fresh.
  2. Use SAVEPOINT and ROLLBACK TO SAVEPOINT to recover within the transaction.
  3. Fix the original failing statement that aborted the transaction.

Related & next steps

Reference: PostgreSQL 18 Section 3.4 “Transactions”.

Was this helpful?