4094xx
4xx — Client Error
Conflict
The request could not be completed due to a conflict with the current state of the target resource.
What it means
The HTTP 409 Conflict response status code indicates a request conflict with the current state of the target resource.
Conflicts are most likely to occur in response to a PUT request. For example, you may get a 409 response when uploading a file that is older than the existing one on the server, resulting in a version control conflict.
How it works
- 1The client attempts to create or modify a resource.
- 2The server checks the database and realizes doing so would violate a unique constraint or business rule.
- 3The server rejects the request with a 409 Conflict.
Why you're seeing this
- • Violating a unique database constraint.
- • Simultaneous edit conflicts (Optimistic Concurrency Control).
How to fix it
- • Prompt the user to choose a different value, or fetch the latest version of the resource and merge their changes.
Framework Implementations
Express.js
app.post('/register', async (req, res) => {
const exists = await User.findOne({ email: req.body.email });
if (exists) return res.status(409).json({ error: 'Email taken' });
});Real-Life Scenarios
Use this when a user tries to register with an email that already exists, or when two users try to edit the same wiki page simultaneously.
Duplicate Username
A user tries to register the username 'admin'. The database has a UNIQUE constraint on usernames. The server returns 409.
HTTP Transaction
1. Client Request
POST /api/users HTTP/1.1
{"email": "existing@example.com"}2. Server Response
HTTP/1.1 409 Conflict
Content-Type: application/json
{"error": "A user with this email already exists."}SEO Implications
None.