PostgreSQLRunbook 0/2 done
23503

PostgreSQL Error 23503: Foreign key violation

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

The referenced parent row does not exist, or you deleted a parent that still has children. Insert parents first, or declare ON DELETE CASCADE / SET NULL.

Identify: does your log match?

What you see · exact log / response
ERROR:  insert or update on table "posts" violates foreign key constraint "posts_author_id_fkey"
DETAIL:  Key (author_id)=(42) is not present in table "users".

Fix

Being written

Copy-paste fixes for 23503 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-11 · Source: Official Appendix A error codes (errcodes.txt in the postgres repo) · Official docs ↗ · ~6,600 searches/mo