HTTP 412 Precondition Failed
HTTP 412 Precondition Failed means a condition the client set in a request header, such as If-Match or If-Unmodified-Since, was false on the server.
Quick answer
HTTP 412 Precondition Failed means a condition the client set in a request header, such as If-Match or If-Unmodified-Since, was false on the server. It is the standard way to stop lost updates: the edit is rejected because the resource changed since the client read it.
Last updated · Maintained by FreeAIToolz · How we test
What does HTTP 412 Precondition Failed mean?
A client reads a resource and its ETag, then sends an update with If-Match: "<etag>". If someone else changed the resource first, the ETag no longer matches and the server returns 412 instead of overwriting their changes.
| Status code | 412 |
|---|---|
| Name | Precondition Failed |
| Class | 4xx Client Error |
| Defined in | RFC 9110 §15.5.13 |
| Cacheable by default | No, unless Cache-Control says so |
| Safe to retry automatically? | No: change the request first |
| Related headers | If-Match, If-Unmodified-Since, ETag |
What causes HTTP 412?
- The resource changed after the client fetched it (ETag mismatch).
- An If-Unmodified-Since date that is older than the resource’s last change.
How do I fix HTTP 412?
- Return the current ETag so the client can re-sync.
- Use 428 Precondition Required if you want to force clients to send If-Match.
What should a client do after HTTP 412?
Re-fetch the resource, merge changes and retry with the new ETag.
Does HTTP 412 affect SEO?
No SEO impact.
Example 412 response
HTTP/1.1 412 Precondition Failed
Date: Mon, 01 Dec 2026 12:00:00 GMT
Content-Type: application/json
{"error":{"status":412,"message":"Precondition Failed"}} How to return 412 Precondition Failed in code
Express (Node.js)
res.status(412).json({ error: 'Precondition Failed' }); Next.js route handler
return Response.json({ error: 'Precondition Failed' }, { status: 412 }); FastAPI (Python)
raise HTTPException(status_code=412, detail="Precondition Failed") PHP
http_response_code(412); Nginx
location = /example {
return 412;
} Other 4xx status codes
The request contains an error or cannot be fulfilled as sent. Fix the request before retrying.
- 400 Bad Request
- 401 Unauthorized
- 402 Payment Required
- 403 Forbidden
- 404 Not Found
- 405 Method Not Allowed
- 406 Not Acceptable
- 407 Proxy Authentication Required
- 408 Request Timeout
- 409 Conflict
- 410 Gone
- 411 Length Required
- 413 Content Too Large
- 414 URI Too Long
- 415 Unsupported Media Type
- 416 Range Not Satisfiable
- 417 Expectation Failed
- 418 I'm a teapot
- 421 Misdirected Request
- 422 Unprocessable Content
- 423 Locked
- 425 Too Early
- 426 Upgrade Required
- 428 Precondition Required
- 429 Too Many Requests
- 431 Request Header Fields Too Large
- 451 Unavailable For Legal Reasons
- 499 Client Closed Request
Frequently asked questions
412 vs 409?
How do ETags prevent lost updates?
Is 412 a client or server error?
Related
- 409 Conflict HTTP 409 Conflict means the request conflicts with the current state of the resource.
- 428 Precondition Required HTTP 428 Precondition Required means the server requires the request to be conditional, typically by including.
- 304 Not Modified HTTP 304 Not Modified means the client’s cached copy is still valid, so the server sends no body.
- Open the HTTP Status Codes Reference → Free, no signup.