What Is a 412 Status Code?
One or more conditions given in the request header fields evaluated to false when tested on the server.
This response code allows the client to place preconditions on the current resource state (its current representations and metadata) and, thus, prevent the request method from being applied if the target resource is in an unexpected state.
- Source: RFC7232 Section 4.2
412 CODE REFERENCES
Rails HTTP Status Symbol :precondition_failed
Go HTTP Status Constant http.StatusPreconditionFailed
Symfony HTTP Status Constant Response::HTTP_PRECONDITION_FAILED
Python2 HTTP Status Constant httplib.PRECONDITION_FAILED
Python3+ HTTP Status Constant http.client.PRECONDITION_FAILED
Python3.5+ HTTP Status Constant http.HTTPStatus.PRECONDITION_FAILED
When is a 412 status code used?
An HTTP 412 status code is used for HTTP requests are not HTTP method HEAD or HTTP method GET.
When the 412 precondition failed error message is received, the client will know that one or more of the conditions in the request has failed and the resource will not be retrieved in the expected format or state.
Will search engines index a URL with a 412 status code?
No. Search engines like Google will not index a URL with the HTTP 412 precondition failed status code. That means that URLs that have been previously indexed but are now returning a 412 response status will likely suffer a loss in their search result rankings.
412 status code example
Want to see a 412 response code in action? Check out the 412 example below. In this example, the client is requesting to leave a comment on an article but only wants their response to be recorded if the article hasn’t been updated since they last viewed it.
If this article has been modified, the server will respond with a 412 precondition failed status error to demonstrate that the client’s request hasn’t been fulfilled.
Request
POST /examplearticle/update?postid=123&task=reply HTTP/1:1
Host: www.example.com
If-unmodified-since: 13 March 2023 0:00:00 GMT
Content-type: text/plain
Content length: 30
<message body from client>
Response
HTTP/1:1 412 Precondition Failed
Content type: text/plain
Content length: 60
<html>
<head>
<title> Article Update Error <title>
<head>
<body>
<p> This article has been updated since you recorded your comment, so your response will not be posted.<>;p>
<body>
</html>
Which browsers are compatible with a 412 response code?
The following browsers will issue an HTTP 412 response code:
- Google Chrome
- Microsoft Edge
- Firefox
- Opera
- Safari
- Chrome Android
- Safari on iOS
- Samsung Internet
WebView Android
Additional resources
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs
- W3Schools
Marketing Tips for Niche Industries
- Travel and Tourism Marketing Budget
- Urgent Care Marketing Ideas: 5 High-ROI Tactics
- Vision Care Industry Statistics
- WebFX: Your Education Digital Marketing Agency
- Why Auto Part Retailers Need Digital Marketing
- Why Digital Marketing is Essential for Auctioneers
- Your Guide to Digital Marketing for Exercise Equipment Companies
- Your Guide to Digital Marketing for Industrial Repair Companies
- 2025 Professional Services Trends: Embracing the Future
- 6 Best Heavy Equipment Marketing Agencies