# ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification

**Code:** `42P10` · **Category:** PostgreSQL · **Seen on:** PostgreSQL

INSERT … ON CONFLICT (cols) names columns that don’t have a matching unique index/constraint.

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

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/postgresql/no-unique-constraint-matching-on-conflict)
