HTTP 409 Conflict
4xx Client Error
- Home
- HTTP Status Codes
- 4xx
- 409
What is HTTP 409 Conflict?
The 409 (Conflict) status code indicates that the request could not be completed due to a conflict with the current state of the target resource. This is commonly used in version control systems and collaborative editing applications where conflicts arise from concurrent modifications.
Common Use Cases
- Version conflict during resource update
- Editing a resource that has been modified by another user
- Duplicate entry creation attempt
Usage Example
When two users simultaneously edit the same document, the second user's save request should include the version they last saw. If the server detects the version is outdated, return 409 Conflict with details about what changed and a link to the latest version so the client can merge.
// Laravel - optimistic locking with 409
$post = Post::findOrFail($id);
if ($request->input('version') !== $post->version) {
return response()->json([
'error' => 'Version conflict',
'latest_version' => $post->version,
'latest_content' => $post->content,
], 409);
}
Related Status Codes
Common Mistakes
Mistake: Using 409 for validation errors instead of 422
Fix: Use 409 specifically for conflicts with the current state (e.g., stale version, duplicate). Use 422 for request body validation errors that do not depend on server state.
Mistake: Not providing enough information to resolve the conflict
Fix: A 409 response should include details about what the conflict is and how the client can resolve it, such as the current server state or the specific conflicting fields.