Skip to content

Common codes

A curated list of SQLSTATE values useful during incident triage.

This is an editorial entry point for frequent diagnosis paths. It is not a measured ranking of production frequency; each row states the practical question the entry helps answer and preserves its review state.

Code Condition Why start here
23505 unique_violation Duplicate keys, constraints, and idempotent writes.
23503 foreign_key_violation Foreign-key repair and dependency order.
23502 not_null_violation Missing required values and input validation.
23514 check_violation CHECK constraints and invariant failures.
23P01 exclusion_violation Exclusion constraints and range conflicts.
40P01 deadlock_detected Deadlock diagnosis, rollback, and lock ordering.
40001 serialization_failure Serializable retry and fresh transaction snapshots.
25P02 in_failed_sql_transaction The failed transaction state that follows an error.
42P01 undefined_table Missing relations and search-path diagnosis.
42601 syntax_error Syntax errors before a statement can execute.
42501 insufficient_privilege Privilege checks and authorization failures.
28P01 invalid_password Password authentication and connection setup.
57014 query_canceled Cancellation, statement_timeout, and safe follow-up.
53300 too_many_connections Connection limits and admission failures.
2202E array_subscript_error Array dimensions, concatenation, and type rules.
01000 warning Warning dispatch and non-error diagnostics.
P0001 raise_exception Application-defined PL/pgSQL exceptions.
XX000 internal_error Internal-error safety boundaries and escalation.