🐘 PostgreSQL errors

PostgreSQL connection, authentication and query errors.

CodeErrorWhat it means
57014 ERROR: canceling statement due to statement timeout A query ran longer than statement_timeout and PostgreSQL cancelled it.
08P01 ERROR: bind message supplies 2 parameters, but prepared statement requires 1 The number of query parameters sent doesn’t match the $1, $2 … placeholders in the SQL.
2BP01 ERROR: cannot drop table x because other objects depend on it Views, foreign keys or other objects depend on what you’re dropping.
42804 ERROR: column "x" is of type integer but expression is of type text — HINT: You will need to rewrite or cast the expression. An INSERT/UPDATE supplies a value of a different type than the column, and PostgreSQL won’t cast implicitly.
42701 ERROR: column "x" of relation "y" already exists ALTER TABLE ADD COLUMN for a column that’s already there.
42P18 ERROR: could not determine data type of parameter $1 PostgreSQL can’t infer a parameter’s type from context (e.g. $1 IS NULL or SELECT $1).
53100 ERROR: could not extend file "base/…": No space left on device The disk holding the PostgreSQL data directory (or WAL) is full.
extension not available ERROR: could not open extension control file ".../postgis.control": No such file or directory CREATE EXTENSION failed because the extension’s files aren’t installed on the server.
40001 ERROR: could not serialize access due to concurrent update A REPEATABLE READ/SERIALIZABLE transaction conflicted with a concurrent one and must be retried.
25P02 ERROR: current transaction is aborted, commands ignored until end of transaction block An earlier statement in the same transaction failed; PostgreSQL rejects everything until you ROLLBACK.
currval not defined ERROR: currval of sequence "x" is not yet defined in this session currval() was called before nextval() in the same session.
55006 ERROR: database "x" is being accessed by other users — There is 1 other session using the database. DROP/RENAME DATABASE can’t run while other sessions are connected.
22008 ERROR: date/time field value out of range: "31/12/2024" — HINT: Perhaps you need a different "datestyle" setting. PostgreSQL parsed a date in the wrong order (DMY vs MDY) or got an impossible value.
42883 function ERROR: function x(text) does not exist — No function matches the given name and argument types PostgreSQL found no function with that name and argument types — wrong types, missing extension, or schema no…
23503 ERROR: insert or update on table "x" violates foreign key constraint "fk" — Key (user_id)=(5) is not present in table "users" The row references a parent row that doesn’t exist.
22021 ERROR: invalid byte sequence for encoding "UTF8": 0x00 Text contained bytes invalid in UTF-8 — often a NUL byte (0x00) or Latin-1/Windows-1252 data.
22P02 ERROR: invalid input syntax for type integer: "abc" A string couldn’t be converted to the column’s type (integer, numeric, boolean, date…).
22P02 uuid ERROR: invalid input syntax for type uuid: "x" A value that isn’t a valid UUID was compared with or inserted into a uuid column.
malformed array literal ERROR: malformed array literal: "x" A value sent to an array column isn’t in PostgreSQL array syntax ({a,b}).
missing FROM-clause ERROR: missing FROM-clause entry for table "x" The query references a table/alias that isn’t in the FROM clause (or uses the wrong alias).
23514 ERROR: new row for relation "x" violates check constraint "y" A value failed a CHECK constraint (e.g. price > 0, status IN (…)).
23502 ERROR: null value in column "x" of relation "y" violates not-null constraint An INSERT/UPDATE put NULL into a NOT NULL column.
22003 ERROR: numeric field overflow — A field with precision 5, scale 2 must round to an absolute value less than 10^3 A number doesn’t fit the column’s numeric(precision, scale) or integer range.
42883 operator ERROR: operator does not exist: integer = text A comparison or operation mixes types PostgreSQL won’t implicitly convert.
out of shared memory ERROR: out of shared memory — HINT: You might need to increase max_locks_per_transaction. A transaction took more locks than the lock table can hold — usually touching many tables/partitions at once.
create extension denied ERROR: permission denied to create extension "x" — Must be superuser to create this extension. Your role lacks the privilege to create that extension.
prepared statement exists ERROR: prepared statement "s1" already exists (PgBouncer transaction mode) Named prepared statements collided — typically because PgBouncer in transaction pooling mode hands connection…
42P07 ERROR: relation "x" already exists CREATE TABLE/INDEX/SEQUENCE used a name that already exists in that schema.
42601 ERROR: syntax error at or near "x" PostgreSQL couldn’t parse the SQL; the token shown is where parsing failed.
42P10 ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification INSERT … ON CONFLICT (cols) names columns that don’t have a matching unique index/constraint.
23503 parent ERROR: update or delete on table "users" violates foreign key constraint on table "orders" — Key (id)=(5) is still referenced You tried to delete a row that other rows still reference.
22001 ERROR: value too long for type character varying(255) A string exceeds the column’s varchar length.
data directory permissions FATAL: data directory "/var/lib/postgresql/data" has invalid permissions — Permissions should be u=rwx (0700) or u=rwx,g=rx (0750). PostgreSQL refuses to start because the data directory is too open or owned by the wrong user.
3D000 FATAL: database "x" does not exist The connection names a database that isn’t on that server.
incompatible data directory FATAL: database files are incompatible with server — The data directory was initialized by PostgreSQL version 15, which is not compatible with this version 16 A newer (or older) PostgreSQL major version was started on an existing data directory.
postmaster.pid FATAL: lock file "postmaster.pid" already exists — Is another postmaster running in data directory? PostgreSQL won’t start because a stale postmaster.pid file remains (or another instance really is running).
role does not exist FATAL: role "x" does not exist PostgreSQL has no login role with that name.
53300 FATAL: sorry, too many clients already / remaining connection slots are reserved for non-replication superuser connections PostgreSQL reached max_connections.
idle-in-transaction timeout FATAL: terminating connection due to idle-in-transaction timeout A session opened a transaction and sat idle longer than idle_in_transaction_session_timeout.
recovery mode FATAL: the database system is in recovery mode PostgreSQL crashed (often OOM-killed) and is replaying WAL to recover.
57P03 FATAL: the database system is starting up PostgreSQL is still starting (or recovering) and not accepting connections yet.
connection limit for role FATAL: too many connections for role "x" The role reached its per-role CONNECTION LIMIT (often set by hosting providers or free tiers).
port 5432 in use LOG: could not bind IPv4 address "0.0.0.0": Address already in use — Is another postmaster already running on port 5432? Another process (often a second PostgreSQL install or a container) already listens on 5432.
pg_dump version mismatch pg_dump: error: aborting because of server version mismatch Your pg_dump client is older than the server you’re dumping.
pg_restore text dump pg_restore: error: input file appears to be a text format dump. Please use psql. A plain .sql dump was given to pg_restore, which only reads custom/directory/tar formats.
could not connect PostgreSQL: could not connect to server / connection refused — Is the server running on host and accepting TCP/IP connections? The client reached no PostgreSQL listener at that host/port — the server is down, listening elsewhere, or not…
42703 PostgreSQL: ERROR: column "x" does not exist PostgreSQL can’t find the column — a missing migration, a case-sensitive quoted name, or a string literal wri…
23505 PostgreSQL: ERROR: duplicate key value violates unique constraint An INSERT/UPDATE would create a duplicate in a UNIQUE or PRIMARY KEY column — or the id sequence is behind th…
42501 PostgreSQL: ERROR: permission denied for table / schema public The role is connected but lacks privileges on that table or schema — very common after PostgreSQL 15 removed…
42P01 PostgreSQL: ERROR: relation "x" does not exist The table/view isn’t found — missing migration, wrong schema, or a case-sensitive quoted name.
28P01 PostgreSQL: FATAL: password authentication failed for user PostgreSQL rejected the password for that role, or pg_hba.conf requires a different auth method.
connection closed server closed the connection unexpectedly — This probably means the server terminated abnormally before or while processing the request. The connection to PostgreSQL dropped — the server restarted/crashed, a proxy/firewall killed an idle connecti…
SSL required server does not support SSL, but SSL was required / no pg_hba.conf entry … no encryption The client and server disagree about SSL — the client requires it but the server doesn’t offer it, or the ser…