SQLSTATE XX000 PANIC Class XX: Internal Error

internal_error Internal Error — SQLSTATE XX000

PostgreSQL hit an internal error or unexpected state.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Symptoms

PostgreSQL hit an internal error or unexpected state.

  • The error is written to the server log and returned to the client carrying SQLSTATE XX000.
  • Any driver (libpq, JDBC, psycopg, npgsql, pgx) surfaces this code in its error object so you can branch on it programmatically.

Environment

Severity: PANIC  |  PostgreSQL versions: 12, 13, 14, 15, 16, 17

Indicates a system- or storage-level problem; inspect OS logs, disk health, and any recent hardware or filesystem changes.

Root Cause

An internal invariant failed — frequently corruption or a server bug.

Diagnostic Queries

Recovery

Steps to resolve XX000:

  1. Capture the full log, including any backtrace.
  2. Run integrity checks with pg_amcheck and verify hardware/memory.
  3. Search the message against known issues for your version and report reproducible cases.
  4. If corruption is suspected, restore from a known-good backup.

Reference: PostgreSQL error codes — Class XX (Internal Error).

Was this helpful?