ERROR: null value in column "x" of relation "y" violates not-null constraint
An INSERT/UPDATE put NULL into a NOT NULL column.
Seen on:
PostgreSQL
Meaning
The DETAIL line shows the failing row. Missing input fields, ORM attributes not set, or a new NOT NULL column without a default are typical.
Common causes
- Required field missing from input
- New NOT NULL column added without DEFAULT on existing rows
- Explicit NULL instead of omitting the column
- id column without a sequence/identity
⚡ Quick fix
- Validate required fields
- Add a DEFAULT, backfill, then set NOT NULL
- Use GENERATED ALWAYS AS IDENTITY for ids
Detailed fix by platform
PostgreSQL
ALTER TABLE users ADD COLUMN status text NOT NULL DEFAULT 'active';
How to diagnose
- Column — Which one?
- Row — DETAIL failing row
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026