HTTP 412 Precondition Failed — What It Means & How to Fix It
Error4xx client error
Overview
The HTTP 412 Precondition Failed status code indicates one or more conditions specified in the request headers evaluated to false on the server.
Key Details
- This occurs when conditional headers like If-Match or If-Unmodified-Since fail their checks.
- It is used in optimistic concurrency control to prevent lost updates.
- The client should fetch the latest version and retry with updated preconditions.
- Common in APIs that use ETags for conflict detection.
Common Causes
- The If-Match header contains an ETag that no longer matches the current resource.
- The If-Unmodified-Since date is older than the resource last modification time.
- Another client modified the resource between your GET and PUT/PATCH.
Steps
- 1Fetch the latest version of the resource to get the current ETag.
- 2Merge your changes with the latest version.
- 3Retry the request with the updated ETag in the If-Match header.
- 4Implement retry logic for concurrent modification scenarios.
Tags
httpclient-errorpreconditionetagconcurrency
Related Items
More in 4xx Client Error
http-400-bad-requestHTTP 400 Bad Request — What It Means & How to Fix It
Errorhttp-401-unauthorizedHTTP 401 Unauthorized — What It Means & How to Fix It
Errorhttp-402-payment-requiredHTTP 402 Payment Required — What It Means & How to Fix It
Errorhttp-403-forbiddenHTTP 403 Forbidden — What It Means & How to Fix It
Errorhttp-404-not-foundHTTP 404 Not Found — What It Means & How to Fix It
Errorhttp-405-method-not-allowedHTTP 405 Method Not Allowed — What It Means & How to Fix It
ErrorFrequently Asked Questions
It means a condition specified in the request headers (like If-Match or If-Unmodified-Since) was not met. The resource may have been modified by someone else.