412 Precondition Failed HTTP Status Code


HTTP status code 412, also known as "Precondition Failed," is a client error status code that indicates that one or more conditions given in the request header fields evaluated to false when tested on the server. This status code is primarily used with conditional request headers, such as If-Match, If-None-Match, If-Modified-Since, If-Unmodified-Since, and If-Range, which are used to specify conditions that must be met for the requested operation to proceed.

For example, a client might send an If-Match header in a request to update a resource, containing an entity tag (ETag) that represents a specific version of the resource. If the current version of the resource on the server does not match the ETag provided in the If-Match header, the server will respond with a 412 status code, indicating that the precondition has failed and the request will not be fulfilled. This mechanism is often used to prevent lost updates and conflicts in web applications, by ensuring that a resource has not been modified by another party before it is updated or deleted.


412 Precondition Failed

Common Causes

This status code is primarily associated with conditional requests, which use header fields like If-Match, If-None-Match, If-Modified-Since, If-Unmodified-Since, and If-Range to make the request and subsequent processing conditional.

Here are some common causes for receiving a HTTP status code 412:

  1. Mismatched ETag: The If-Match header is used to make the request conditional on the target resource's current ETag (Entity Tag) matching a given ETag value. If the ETag for the resource does not match the value specified in the If-Match header, the server will return a 412 error.

  2. Modified Resource: Similarly, if an If-Unmodified-Since header is included in the request, the server will check the modification date of the resource against the date specified. If the resource has been modified after the date specified, a 412 status code is returned.

  3. Unmet Range Requests: The If-Range header allows a client to request only a portion of the resource if the specified condition (usually an ETag or a last modified date) matches. If the condition does not match, indicating that the cached copy of the resource is out of date, a 412 error can be returned instead of the requested range.

  4. Other Conditional Headers Not Met: Similar principles apply to other conditional headers like If-None-Match and If-Modified-Since, but these typically result in different status codes (304 Not Modified, for instance) when their conditions are not met. However, misconfigurations or specific server logic could potentially lead to a 412 error in these cases as well.

To resolve a 412 error, the client needs to ensure that the conditions set in the request headers accurately reflect the desired state of the resource and the current state of their local cache or knowledge about the resource. This often involves updating the condition values based on the current state of the resource as communicated by the server in previous responses.

Browser Support

The following table will show you the current browser support for the 412 Precondition Failed HTTP status code.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 1st April 2024