PostgreSQL Error Codes

PostgreSQL Error Codes: Complete reference of PostgreSQL error codes (SQLSTATE) with… Searchable index with fixes, code examples, and official sources.

20 error codes PostgreSQL Last verified 2026-08-19

All 20 error codes

23505 Unique Violation A unique constraint or exclusion constraint was violated while inserting or updating a row, because a... 42601 Syntax Error The SQL statement contains a syntax error and could not be parsed. 42P01 Undefined Table The referenced table does not exist in the current schema search path. 23503 Foreign Key Violation A foreign key constraint was violated because a referenced row does not exist, or an operation would... 42703 Undefined Column The referenced column does not exist in the table. 08006 Connection Failure The connection to the server failed during the operation. 40P01 Deadlock Detected The transaction was aborted because it was selected as the deadlock victim to break a deadlock cycle. 08001 Sqlclient Unable to Establish Sqlconnection The SQL client could not establish a connection to the SQL server. 23502 Not Null Violation A NOT NULL constraint was violated by inserting or updating a column with a NULL value. 42501 Insufficient Privilege The current user lacks the privilege required to perform the operation. 40001 Serialization Failure The transaction was aborted due to a serialization failure in a SERIALIZABLE or REPEATABLE READ transaction. 08003 Connection Does Not Exist The operation was attempted on a connection that does not exist (already closed or never opened). 23514 Check Violation A CHECK constraint was violated because a row did not satisfy the constraint expression. 42883 Undefined Function The referenced function does not exist, or no function matches the given argument types. 57014 Query Canceled The query was canceled, typically by a user request, statement_timeout, or idle_in_transaction_timeout. 55P03 Lock Not Available A lock requested with the NOWAIT option could not be acquired immediately and the statement was aborted. 22001 String Data Right Truncation A string value was too long for the column's character type and was truncated, which is not allowed. 22003 Numeric Value Out of Range A numeric value is out of the range allowed by the column type or operation. 42P02 Undefined Parameter The referenced prepared-statement parameter does not exist. 22012 Division by Zero Division by zero was attempted.

Official Sources