Skip to the content

412 Precondition Failed

A condition in the request headers, such as If-Match, turned out to be false, so the server did not carry the request out.

Class
4xx Client error. The request is the problem: a wrong address, missing credentials, data the server can't accept.
Defined in
RFC 9110

What it looks like

HTTP/1.1 412 Precondition Failed
ETag: "7c1-9d2"

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

What causes it

When a client makes its request depend on the state of the resource and that state is different. The classic use is safe editing: the client sends the ETag of the version it loaded in If-Match, and if someone else saved in the meantime, the ETag no longer matches and the update is refused.

What to do about it

Nothing was changed. Fetch the resource again, apply your change to the new version and send it with the new ETag.

If you get a 412 without having set a condition, look for a library or a proxy that adds If-Match or If-Unmodified-Since for you. For a GET, the answer to a failed condition is 304 and not 412.

Not to be confused with

409 ConflictA conflict that the server found by itself, without a condition from the client.
428 Precondition RequiredThe server insists on a condition and the request had none.
304 Not ModifiedThe outcome of a condition on a GET: use the copy you have.

All codes are on the list of HTTP status codes, which can be searched by number and by word.

See all 12