Qaynaq LABS · TOOLS

HTTP · 4xx Client Error

409 Conflict

Request conflicts with current server state; cannot be completed.

When you see this status

  • Updating a resource with stale data (e.g., version mismatch)
  • Creating a duplicate resource with unique constraints
  • Concurrent modifications causing inconsistency
  • Race conditions in distributed systems

Common causes

  • Optimistic locking failures (e.g., ETag/version mismatch)
  • Unique constraint violations in databases
  • Inconsistent state due to concurrent requests
  • Business rule violations (e.g., invalid state transition)

How to debug it

  1. Check request payload for conflicts with existing state
  2. Verify resource version/ETag headers if applicable
  3. Inspect server logs for concurrent modification traces
  4. Validate business logic constraints before processing

Return this code in your framework

Express (Node.js)
res.status(409).json({ error: 'Conflict', message: 'Resource version mismatch' });
FastAPI (Python)
return JSONResponse(status_code=409, content={"detail": "Conflict: version mismatch"})
NestJS
@HttpCode(409) @Post() async create(@Body() dto: CreateDto) { throw new ConflictException('Duplicate entry'); }
Go (net/http)
w.WriteHeader(http.StatusConflict); w.Write([]byte(`{"error":"Conflict"}`))

About HTTP 409

HTTP status code 409 Conflict is part of the 4xx Client Error family. Request conflicts with current server state; cannot be completed. Understanding it is essential for backend engineers, API designers, and anyone debugging integrations between services.

The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance: what triggers them, how to debug them in production, and exactly how to return them from common frameworks. Each code page is hand-curated and verified.

Frequently asked

How to handle 409 in a REST API?

Return 409 with a body describing the conflict (e.g., version mismatch). Include details for client resolution.

Is 409 idempotent?

No. Retrying a 409 request may succeed if the conflict is resolved (e.g., after updating state).

Can 409 be cached?

No. Responses with 409 should not be cached due to potential state changes.

How to prevent 409 errors?

Use conditional requests (ETags/If-Match) or implement proper locking mechanisms for concurrent updates.