4xx
412 Precondition Failed
One or more conditions in the request headers evaluated to false on the server.
What is HTTP 412?
This status code indicates that one or more preconditions given in the request headers were evaluated by the server and found to be false. This is used with conditional requests where headers like If-Match, If-Unmodified-Since, or If-None-Match set conditions that must be met for the request to proceed. It prevents unintended overwrites in optimistic concurrency control scenarios.
Defined in RFC 9110
Common Causes
- An If-Match header specified an ETag that no longer matches the current resource version
- An If-Unmodified-Since date is older than the resource's last modification date
- Optimistic locking detected that another client modified the resource since it was last fetched
- Conditional PUT or DELETE requests where the resource state changed unexpectedly
How to Fix
- Fetch the current version of the resource and update your conditional headers before retrying
- Review the resource's current ETag or Last-Modified date and adjust your preconditions
- Implement proper conflict resolution by re-fetching, merging changes, and retrying
- Consider whether the precondition is still necessary or if it can be relaxed