42P10 PostgreSQL Origin: Data OSI layer 7 · Application Last updated 15 Oct 2026

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.

Exact message you may see there is no unique or exclusion constraint matching the ON CONFLICT specification
Seen on: PostgreSQL

Meaning

ON CONFLICT needs an existing unique constraint on exactly those columns (or a matching partial index predicate).

Common causes

  • No unique index on the conflict columns
  • Column order/set differs from the index
  • Partial unique index without WHERE in ON CONFLICT

⚡ Quick fix

  1. Create the unique index on those columns
  2. Match the columns exactly
  3. Use ON CONFLICT ON CONSTRAINT name

Detailed fix by platform

PostgreSQL

  1. CREATE UNIQUE INDEX IF NOT EXISTS users_email_key ON users (email);

How to diagnose

  1. Index — Unique index on those exact columns?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

08P01 — ERROR: bind message supplies 2 parameters, but prepared statement requires 1 (PostgreSQL)08P011093 — 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)117523503 — ERROR: insert or update on table "x" violates foreign key constraint "fk" — Key (user_id)=(5) is not present in table "users" (PostgreSQL)2350323503 parent — ERROR: update or delete on table "users" violates foreign key constraint on table "orders" — Key (id)=(5) is still referenced (PostgreSQL)23503 parent23505 — PostgreSQL: ERROR: duplicate key value violates unique constraint (PostgreSQL)2350523514 — ERROR: new row for relation "x" violates check constraint "y" (PostgreSQL)2351442804 — ERROR: column "x" is of type integer but expression is of type text — HINT: You will need to rewrite or cast the expression. (PostgreSQL)4280442P10

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.