What 409 Conflict Means
The HTTP specification describes 409 as a request that could not be completed because it conflicts with the current state of the target resource. Nothing is wrong with the request's syntax or data as such; it is the timing or the existing data that blocks it. The response body should explain the conflict so the client can resolve it.
409 comes from the application, not from the web server. Nginx and Apache pass it through unchanged.
Typical Cases
- Creating a duplicate: registering a user name, slug, or order number that already exists.
- Editing an outdated version: you loaded a record, someone else saved a change, and your save is based on the old copy.
- Two updates at once: two requests change the same record in parallel and the application refuses the second.
- Publishing a version twice: uploading a package or file version that already exists, where versions cannot be overwritten.
- Wrong order of steps: deleting a record that others still depend on, or shipping an order that is already canceled.
An Example Exchange
A client updates an article and sends the version it last saw inside the body:
curl -i -X PUT https://api.example.com/v1/articles/42 \
-H "Content-Type: application/json" \
-d '{"title":"New title","version":"v7"}'
If the article is already at version 8, the API refuses with 409 and a body such as:
{"error":"conflict","message":"Article was changed by another user","current_version":"v8"}
If the client sends the version in an If-Match header instead, the standard answer to a stale version is 412 Precondition Failed.
The request format with curl is explained in curl POST request.
How a Client Should React
- Fetch the current state of the resource.
- Merge or decide: combine your change with the new version, or show both to the user and let them choose.
- Retry with the new version number.
Do not repeat the same request in a loop. Unlike a 503 or a 429, a 409 does not go away by waiting; the data has to change first.
409 Compared with 412, 422, and 400
| Code | When it is used |
|---|---|
| 400 | Request is malformed |
| 409 | Clashes with current state |
| 412 | A conditional header failed |
| 422 | Data fails validation |
A missing required field is 422, not 409: see 422 Unprocessable Content. Broken JSON is 400: see 400 Bad Request.
When Your Own Application Returns 409
The web server's logs show only that a 409 was sent. The reason is in the application:
- Application log: look for the request at the same time; most frameworks log the exception or the unique key that clashed.
- Response body: read it with
curl -i; a well-built API names the conflicting field. - Database: a unique index that rejects a duplicate is a common source, mapped by the application to 409.
Designing an API That Uses 409
Return 409 only when the client can do something about it, and say what: which field clashes, or which version is current. Use version numbers or ETags on records that several people edit, so lost updates turn into clear conflicts instead of silent overwrites. The full list of codes is in HTTP status codes explained.