What HTTP 412 means
Conditional requests prevent lost updates. A client sends If-Match: "etag" with a PUT. If the resource changed since the client read it, the ETag no longer matches, and the server returns 412 instead of overwriting someone else’s changes.
How to fix a 412 error
- Re-fetch the resource to get the current ETag, merge your changes, and try again.
Retrying
No. Fix the request first; sending it again unchanged will get the same response.
Example response
HTTP/1.1 412 Precondition Failed
Date: Wed, 21 Oct 2026 10:30:00 GMT
Content-Type: application/json
How to return 412
res.status(412).json({ error: 'Precondition Failed' });
from fastapi import HTTPException
raise HTTPException(status_code=412, detail="Precondition Failed")
http.Error(w, http.StatusText(http.StatusPreconditionFailed), http.StatusPreconditionFailed)
location /private/ {
return 412;
}
Related status codes
- 428 Precondition Required : The server requires the request to be conditional, e.g. with If-Match.
- 409 Conflict : The request conflicts with the current state of the resource.
- 304 Not Modified : Tells the client its cached copy is still valid, so no body is sent.
Other 4xx status codes
400 Bad Request · 401 Unauthorized · 402 Payment Required · 403 Forbidden · 404 Not Found · 405 Method Not Allowed · 406 Not Acceptable · 407 Proxy Authentication Required · 408 Request Timeout · 409 Conflict · 410 Gone · 411 Length Required · 413 Content Too Large · 414 URI Too Long · 415 Unsupported Media Type · 416 Range Not Satisfiable · 417 Expectation Failed · 418 I’m a Teapot · 421 Misdirected Request · 422 Unprocessable Content · 423 Locked · 424 Failed Dependency · 425 Too Early · 426 Upgrade Required · 428 Precondition Required · 429 Too Many Requests · 431 Request Header Fields Too Large · 444 No Response · 451 Unavailable For Legal Reasons · 499 Client Closed Request
See the full list of HTTP status codes.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What does HTTP 412 Precondition Failed mean?
HTTP 412 Precondition Failed means a condition in the request headers, such as If-Match, was not met. Conditional requests prevent lost updates. A client sends If-Match: "etag" with a PUT. If the resource changed since the client read it, the ETag no longer matches, and the server returns 412 instead of overwriting someone else’s changes.
How do I fix HTTP 412?
Re-fetch the resource to get the current ETag, merge your changes, and try again.