Prisma ORMRunbook 0/2 done
P2003

Prisma ORM Error P2003: Foreign key constraint failed

Error✕ Not retryable · fix the payloadHTTP 409 ConflictDatabase
TL;DR · 10-second read

The referenced parent row does not exist, or a delete would orphan children. Create the parent first or set onDelete: Cascade on the relation.

Identify: does your log match?

What you see · exact log / response
PrismaClientKnownRequestError:
Invalid `prisma.post.create()` invocation:

Foreign key constraint violated on the constraint: `Post_authorId_fkey`
  code: 'P2003',
  meta: { modelName: 'Post', constraint: 'Post_authorId_fkey' }

Fix

Being written

Copy-paste fixes for P2003 are in the enrichment queue

The summary above is verified. Paste your full trace into the decoder for a diagnosis now.

Open the decoder →

Related errors

Last verified 2026-10-13 · Source: Prisma error reference P1000–P6010 · Official docs ↗ · ~4,400 searches/mo