Duplicate Key Value Violates Unique Constraint in PostgreSQL

What This Error Means

This error occurs when inserting a record with a value that already exists in a unique column.

Example

INSERT INTO users(id, email) VALUES (1, 'test@example.com');

If ID 1 already exists, the insert fails.

Fix Options