4xx Client Errors
HTTP 412 Precondition Failed
One or more conditions in the request header fields evaluated to false.
When is 412 used?
- If-Match ETag mismatch during updates
- Optimistic concurrency control
How to handle a 412 response
Inspect the request — URL, method, headers, credentials, and body. Retrying the same request unchanged will usually fail again; 429 is the exception, where you should wait for the Retry-After period.
Check the status code a URL returns from the command line:
curl -s -o /dev/null -w "%{http_code}\n" https://example.comHow to return 412 from your server
Node.js (Express)
res.status(412).json({ message: 'Precondition Failed' });Python (Flask)
return {"message": "Precondition Failed"}, 412Go (net/http)
w.WriteHeader(412)Frequently Asked Questions
What does HTTP 412 mean?
412 Precondition Failed: One or more conditions in the request header fields evaluated to false.
Is 412 an error?
Yes. 412 is in the 4xx Client Errors class. Client errors: the request is malformed, unauthorized, or targets something that does not exist.