412 Precondition Failed
One or more conditions given in the request headers evaluated to false on the server.
Definition (RFC 9110)
HTTP status code 412 412 Precondition Failed is defined in RFC 9110 (HTTP Semantics), Section 15.5.13 — the current authoritative specification for HTTP semantics, published June 2022, which obsoletes the older RFC 7231 and RFC 2616.
Description
412 Precondition Failed occurs when conditional request headers (If-Match, If-None-Match, If-Modified-Since, If-Unmodified-Since) evaluate to false. This is used to prevent mid-air collisions: if a resource has been modified since you last read it, your update is rejected.
Essential for optimistic concurrency control in REST APIs.
Common Causes
- Resource was modified by another client between read and write (lost update)
- Stale
ETagvalue inIf-Matchheader - Conditional GET where the resource hasn't changed
- Cache validation failure
How to Fix
- Re-fetch the resource to get the latest
ETagbefore updating - Implement merge strategies or conflict resolution UI
- Use optimistic locking: include version number or ETag in update requests
- Inform the user that the resource was updated by someone else
Check your website's HTTP status code
Check now →