Error map

23505 PostgreSQL: ERROR: duplicate key value violates unique constraint

PostgreSQL · layer 5, Data

Open the full error page →

Centre: this error. First ring: errors it is linked with (12). Outer ring: what those are linked with. Colours show the layer of a request each error belongs to. Click any dot to re-centre the map on it; hover to follow its connections. The centre dot opens the error page.

23505 — PostgreSQL: ERROR: duplicate key value violates unique constraint (PostgreSQL)235051062 — MySQL ERROR 1062 (23000): Duplicate entry for key (MySQL)1062DbUpdateException — DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details. (.NET)DbUpdateExceptionE11000 duplicate key — MongoServerError: E11000 duplicate key error collection: db.users index: email_1 dup key (Node.js)E11000 duplicate key23502 — ERROR: null value in column "x" of relation "y" violates not-null constraint (PostgreSQL)2350242P10 — ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification (PostgreSQL)42P1023503 — ERROR: insert or update on table "x" violates foreign key constraint "fk" — Key (user_id)=(5) is not present in table "users" (PostgreSQL)2350342703 — PostgreSQL: ERROR: column "x" does not exist (PostgreSQL)42703ActiveRecord::RecordNotUnique: duplicate key value — Rails: ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_email" (Ruby / Rails)ActiveRecord::Recor…515 — SQL Server Msg 515: Cannot insert the value NULL into column 'X', table 'Y'; column does not allow nulls (SQL)515currval not defined — ERROR: currval of sequence "x" is not yet defined in this session (PostgreSQL)currval not defined23514 — ERROR: new row for relation "x" violates check constraint "y" (PostgreSQL)23514ALREADY_EXISTS — API Error: Resource already exists (ALREADY_EXISTS / resource_already_exists / 409) (API)ALREADY_EXISTS1452 — MySQL ERROR 1452: Cannot add or update a child row: a foreign key constraint fails (MySQL)1452Deadlock — Deadlock found when trying to get lock; try restarting transaction (SQL)Deadlock409 — HTTP 409 Conflict (HTTP)409JsonException object cycle — JsonException: A possible object cycle was detected (.NET)JsonException objec…Hibernate ConstraintViolationException — org.hibernate.exception.ConstraintViolationException: could not execute statement (Java)Hibernate Constrain…1022 — MySQL ERROR 1022 (23000): Can't write; duplicate key in table (MySQL)1022buffering timed out — MongooseError: Operation `users.find()` buffering timed out after 10000ms (Node.js)buffering timed outMongoServerSelectionError — MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 (Node.js)MongoServerSelectio…CastError ObjectId — CastError: Cast to ObjectId failed for value "x" (type string) at path "_id" (Node.js)CastError ObjectId1048 — MySQL ERROR 1048 (23000): Column 'x' cannot be null (MySQL)104823503 parent — ERROR: update or delete on table "users" violates foreign key constraint on table "orders" — Key (id)=(5) is still referenced (PostgreSQL)23503 parent22P02 — ERROR: invalid input syntax for type integer: "abc" (PostgreSQL)22P021093 — MySQL ERROR 1093 (HY000): You can't specify target table 'x' for update in FROM clause (MySQL)10931175 — MySQL ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column (MySQL)117508P01 — ERROR: bind message supplies 2 parameters, but prepared statement requires 1 (PostgreSQL)08P011451 — MySQL ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (MySQL)1451TRUNCATE — Cannot truncate a table referenced by a FOREIGN KEY constraint (SQL)TRUNCATEforeign key order — Foreign key violation caused by insert order or circular references (SQL)foreign key order1054 — MySQL ERROR 1054 (42S22): Unknown column in 'field list' (MySQL)105442P01 — PostgreSQL: ERROR: relation "x" does not exist (PostgreSQL)42P01ambiguous column — Column reference is ambiguous / Column 'id' in field list is ambiguous (MySQL 1052) (SQL)ambiguous columnActiveRecord::RecordNotFound: Couldn't find X with 'id'= — Rails: ActiveRecord::RecordNotFound: Couldn't find User with 'id'=42 (Ruby / Rails)ActiveRecord::Recor…ActiveRecord::RecordInvalid: Validation failed — Rails: ActiveRecord::RecordInvalid: Validation failed: Email can't be blank, Name is too short (Ruby / Rails)ActiveRecord::Recor…ActiveRecord::ConnectionNotEstablished — Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found (Ruby / Rails)ActiveRecord::Conne…Prisma P2002 — PrismaClientKnownRequestError P2002: Unique constraint failed on the fields: (`email`) (Node.js)Prisma P2002SQLAlchemy IntegrityError — sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint (Python)SQLAlchemy Integrit…SQLite UNIQUE failed — sqlite3.IntegrityError: UNIQUE constraint failed: users.email (SQL)SQLite UNIQUE failedNonUniqueResultException — IncorrectResultSizeDataAccessException: query did not return a unique result: 2 (Java)NonUniqueResultExce…42883 operator — ERROR: operator does not exist: integer = text (PostgreSQL)42883 operator42P18 — ERROR: could not determine data type of parameter $1 (PostgreSQL)42P1822P02 uuid — ERROR: invalid input syntax for type uuid: "x" (PostgreSQL)22P02 uuidinvalid_type — API Error: Invalid type — expected integer, received string (API)invalid_typeinvalid_value — API Error: Invalid parameter value — must be one of the allowed values / out of range (API)invalid_valueSQLite NOT NULL failed — sqlite3.IntegrityError: NOT NULL constraint failed: table.column (SQL)SQLite NOT NULL fai…2627 — SQL Server: Violation of PRIMARY KEY constraint 'x'. Cannot insert duplicate key in object 'y'. (Msg 2627) (SQL)2627ORA-00001 — ORA-00001: unique constraint (SCHEMA.PK_X) violated (SQL)ORA-00001

Directly related (12)

1062MySQL

MySQL ERROR 1062 (23000): Duplicate entry for key

An INSERT/UPDATE would create a duplicate value in a PRIMARY or UNIQUE key.

DbUpdateException.NET

DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.

SaveChanges failed in the database; the inner exception (SqlException/PostgresException) has the real reason — constraint violati…

E11000 duplicate keyNode.js

MongoServerError: E11000 duplicate key error collection: db.users index: email_1 dup key

An insert/update violated a unique index in MongoDB.

23502PostgreSQL

ERROR: null value in column "x" of relation "y" violates not-null constraint

An INSERT/UPDATE put NULL into a NOT NULL column.

42P10PostgreSQL

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.

23503PostgreSQL

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.

42703PostgreSQL

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 written in double quote…

ActiveRecord::RecordNotUnique: duplicate key valueRuby / Rails

Rails: ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_email"

A unique index rejected an insert/update because the value already exists.

515SQL

SQL Server Msg 515: Cannot insert the value NULL into column 'X', table 'Y'; column does not allow nulls

An INSERT or UPDATE tried to put NULL into a NOT NULL column that has no default.

currval not definedPostgreSQL

ERROR: currval of sequence "x" is not yet defined in this session

currval() was called before nextval() in the same session.

23514PostgreSQL

ERROR: new row for relation "x" violates check constraint "y"

A value failed a CHECK constraint (e.g. price > 0, status IN (…)).

ALREADY_EXISTSAPI

API Error: Resource already exists (ALREADY_EXISTS / resource_already_exists / 409)

The create request was refused because an object with the same unique identity — name, email, external ID — already exists.

Two steps away (36)

1452MySQL

MySQL ERROR 1452: Cannot add or update a child row: a foreign key constraint fails

You inserted/updated a row whose foreign key value doesn’t exist in the referenced parent table.

DeadlockSQL

Deadlock found when trying to get lock; try restarting transaction

Two transactions waited on each other’s locks; the database killed one so the other could continue.

409HTTP

HTTP 409 Conflict

The request conflicts with the current state of the resource — e.g. a duplicate or an edit based on an outdated version.

JsonException object cycle.NET

JsonException: A possible object cycle was detected

System.Text.Json found a reference loop (e.g. Order → Customer → Orders → …) while serialising, usually from EF Core navigation p…

Hibernate ConstraintViolationExceptionJava

org.hibernate.exception.ConstraintViolationException: could not execute statement

The database rejected an insert/update because of a constraint (unique, foreign key, not null).

1022MySQL

MySQL ERROR 1022 (23000): Can't write; duplicate key in table

An ALTER/CREATE produced a duplicate key or constraint name — often a foreign key name that already exists in the database.

buffering timed outNode.js

MongooseError: Operation `users.find()` buffering timed out after 10000ms

Mongoose queued a query waiting for a connection that never opened.

MongoServerSelectionErrorNode.js

MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017

The MongoDB driver couldn’t find a reachable server for the connection string.

CastError ObjectIdNode.js

CastError: Cast to ObjectId failed for value "x" (type string) at path "_id"

A value that isn’t a valid 24-hex-character ObjectId was used in an _id query.

1048MySQL

MySQL ERROR 1048 (23000): Column 'x' cannot be null

An INSERT/UPDATE put NULL into a NOT NULL column.

23503 parentPostgreSQL

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.

22P02PostgreSQL

ERROR: invalid input syntax for type integer: "abc"

A string couldn’t be converted to the column’s type (integer, numeric, boolean, date…).

1093MySQL

MySQL ERROR 1093 (HY000): You can't specify target table 'x' for update in FROM clause

An UPDATE/DELETE uses a subquery that reads from the same table, which MySQL doesn’t allow directly.

1175MySQL

MySQL ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

MySQL Workbench’s safe updates mode blocked an UPDATE/DELETE without a key-based WHERE.

08P01PostgreSQL

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.

1451MySQL

MySQL ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails

You tried to delete/update a row that other rows still reference.

TRUNCATESQL

Cannot truncate a table referenced by a FOREIGN KEY constraint

TRUNCATE is refused because another table has a foreign key pointing to it.

foreign key orderSQL

Foreign key violation caused by insert order or circular references

Rows must be inserted parent-first, and two tables that reference each other need deferred constraints or nullable columns.

1054MySQL

MySQL ERROR 1054 (42S22): Unknown column in 'field list'

The query references a column that doesn’t exist in the table (or an unquoted string being read as a column).

42P01PostgreSQL

PostgreSQL: ERROR: relation "x" does not exist

The table/view isn’t found — missing migration, wrong schema, or a case-sensitive quoted name.

ambiguous columnSQL

Column reference is ambiguous / Column 'id' in field list is ambiguous (MySQL 1052)

A column name exists in more than one joined table, so the database doesn’t know which one you mean.

ActiveRecord::RecordNotFound: Couldn't find X with 'id'=Ruby / Rails

Rails: ActiveRecord::RecordNotFound: Couldn't find User with 'id'=42

`find`/`find_by!` didn't find a row, so Rails raises (and renders a 404 in production).

ActiveRecord::RecordInvalid: Validation failedRuby / Rails

Rails: ActiveRecord::RecordInvalid: Validation failed: Email can't be blank, Name is too short

`save!`/`create!`/`update!` raised because validations failed.

ActiveRecord::ConnectionNotEstablishedRuby / Rails

Rails: ActiveRecord::ConnectionNotEstablished: No connection pool for 'ActiveRecord::Base' found

ActiveRecord has no database connection configured or established for this process.

Prisma P2002Node.js

PrismaClientKnownRequestError P2002: Unique constraint failed on the fields: (`email`)

A Prisma create/update violated a unique constraint.

SQLAlchemy IntegrityErrorPython

sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint

A database constraint (unique, foreign key, not null) rejected an insert/update made through SQLAlchemy.

SQLite UNIQUE failedSQL

sqlite3.IntegrityError: UNIQUE constraint failed: users.email

An insert/update duplicated a value in a UNIQUE or PRIMARY KEY column in SQLite.

NonUniqueResultExceptionJava

IncorrectResultSizeDataAccessException: query did not return a unique result: 2

A query expected one row but found several.

42883 operatorPostgreSQL

ERROR: operator does not exist: integer = text

A comparison or operation mixes types PostgreSQL won’t implicitly convert.

42P18PostgreSQL

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).

22P02 uuidPostgreSQL

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.

invalid_typeAPI

API Error: Invalid type — expected integer, received string

A request field has the wrong data type — a string where the API expects a number, a number where it expects a boolean, an object…

invalid_valueAPI

API Error: Invalid parameter value — must be one of the allowed values / out of range

The field has the right type but a value the API doesn’t allow — not in the list of accepted options, too small or large, too lon…

SQLite NOT NULL failedSQL

sqlite3.IntegrityError: NOT NULL constraint failed: table.column

A NULL went into a NOT NULL column in SQLite.

2627SQL

SQL Server: Violation of PRIMARY KEY constraint 'x'. Cannot insert duplicate key in object 'y'. (Msg 2627)

An insert duplicated a primary key or unique constraint value.

ORA-00001SQL

ORA-00001: unique constraint (SCHEMA.PK_X) violated

An insert/update duplicated a value in a unique or primary key constraint.