409 Conflict
The request is well-formed and permitted, but it cannot be applied to the resource as it stands now. Changing the request, or the resource, can make it succeed.
What 409 means
Nothing is wrong with the request when you look at it alone. The problem is the combination of the request and the present state of the thing it targets. The specification reserves the code for cases the user might be able to resolve and resubmit, and asks the server to include enough information in the response to show where the conflict lies.
The same request might have succeeded a minute earlier, or may succeed once something else changes. That separates 409 from 400 and 422, where the request is wrong regardless of state.
Typical situations
- Duplicates. Creating a user with an email address that is already registered, or a record that breaks a unique constraint.
- Concurrent edits. Two people load version 7 of a document; the first saves version 8; the second save is based on a version that no longer exists.
- State that forbids the action. Cancelling an order that has already shipped, publishing something already published, deleting a folder that still has contents.
- Work already in progress. A second request with the same idempotency key arrives while the first is still running, or a deploy is triggered while another has the lock.
- Version control. A merge or push that cannot be applied cleanly.
Resolving a 409 as a client
Do not simply send it again; the state has not changed, so the answer will not either. What to do depends on the case:
- Duplicate: treat it as "already exists". Fetch the existing resource or tell the user the name is taken. If your own retry of a create caused it, the first attempt probably succeeded.
- Stale edit: GET the current version, reapply or merge your change, and submit against the new version.
- Wrong state: show the user the current state. The action they wanted is no longer available.
- In progress: wait and poll, then decide.
Returning 409 from your API
- Put the reason and the current state in the body: which field collided, the current version number, the present status.
- For duplicates, consider a
Locationheader or an ID pointing at the existing resource, unless that would leak another user's data. A sign-up form that answers 409 confirms to anyone that an address has an account. - Map database errors on purpose. A unique-constraint violation that escapes as a 500 is a 409 you forgot to catch.
- If clients send
If-Matchwith anETagand it no longer matches, the precise code is 412 Precondition Failed. Use 409 when the conflict is detected from the content of the request rather than from a precondition header.
409 compared with 412, 422 and 400
| Code | What is wrong | Fix |
|---|---|---|
| 409 Conflict | The request does not fit the resource's current state | Refresh, merge or choose a different value |
| 412 Precondition Failed | An If-Match or If-Unmodified-Since header did not hold | Fetch the new ETag and retry |
| 422 Unprocessable Content | The values are invalid whatever the state | Correct the data |
| 400 Bad Request | The request is malformed | Correct the syntax |
Example 409 response
HTTP/1.1 409 Conflict
Content-Type: application/json
Content-Length: 118
{"error":"version_conflict","message":"Document was modified by another request","current_version":8,"your_version":7}Both version numbers are in the body, so the client knows it has to fetch version 8 and reapply its change.
Defined in RFC 9110, section 15.5.10.
Questions
What does a 409 Conflict error mean?
The server understood the request and you are allowed to make it, but applying it would clash with the current state of the resource: it already exists, someone changed it first, or it is in a state that rules the action out.
Should I return 409 or 422 for a duplicate email address?
409 is the closer fit. The request is valid in isolation and fails only because of what is already stored, which is what a conflict with current state means. Plenty of APIs use 422 for all validation, including uniqueness; being consistent matters more.
Can I retry a request that returned 409?
Not unchanged. Resolve the conflict first: fetch the latest version and reapply your change, pick a different unique value, or accept that the resource already exists. An identical retry gets an identical 409.
What is the difference between 409 and 412?
A 412 means a condition the client put in a header, such as If-Match with an ETag, evaluated to false. A 409 is the server's own judgement that the request conflicts with the resource's state, with no precondition header involved.