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.


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.


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>


HTTP/1:1 412 Precondition Failed

Content type: text/plain

Content length: 60



<title> Article Update Error <title>



<p> This article has been updated since you recorded your comment, so your response will not be posted.&lt>;p>



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

Return to List of HTTP Status Codes