Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

HTTP 412 Precondition Failed means the server checked a condition attached to your request and found that it was false. The usual cause is a stale version: your client tries to update a resource using an older ETag or modification date, but the resource has changed since it was read. Refresh the current version, reconcile your intended change, and retry with the current validator rather than blindly removing the condition.

What HTTP 412 means

HTTP conditional request headers let a client say, in effect, “perform this operation only if the resource is still in the state I expect.” A 412 response means the server evaluated a precondition and did not perform the requested method because that condition was not met. It is not, by itself, evidence that the server is down or that your credentials are wrong. The exact request headers, method, response body, and service-specific instructions matter. RFC 9110 defines the conditional request behavior; MDN’s 412 reference describes the status for web developers.

A common sequence is: a client reads a resource, another user or process changes it, and the first client later tries to save its own update based on the old copy. The server rejects the stale write rather than silently overwriting the newer version. That is a safeguard against lost updates, not necessarily a fault in the server.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which precondition failed?

Start with the conditional headers on the request. A request can carry more than one condition, and RFC 9110 specifies how conditions are evaluated. Do not assume that every 412 is an ETag mismatch: identify the header and compare it with the validator for the current representation.

If-Match and ETags

If-Match supplies one or more entity tags, commonly called ETags. The condition succeeds when a supplied tag strongly matches the current representation’s tag. A mismatch means the client’s version is no longer current. The special value * means that a current representation must exist; it does not name a particular version. If the condition is false, the server must not perform the requested method and may return 412. RFC 9110, Section 13.1.1 states: “An origin server that evaluates an If-Match condition MUST NOT perform the requested method if the condition evaluates to false.”

For example, a client may read a document whose ETag is "v17" and later send a PUT with If-Match: "v17". If another client has already changed the document and the current ETag is now "v18", the old condition no longer matches. The server can reject the write with 412. ETag values are opaque validators: do not try to infer version order or construct a new ETag yourself.

If-Unmodified-Since and dates

If-Unmodified-Since expresses a similar condition using a date instead of an ETag. The selected representation must not have been modified after the date supplied. If it has changed later, the condition is false and the origin server may return 412. This date-based option can be used when a client does not have an entity tag, but it is less precise than an ETag for distinguishing representations. The header’s comparison is based on the origin server’s modification time. See MDN’s If-Unmodified-Since reference and RFC 9110.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If-None-Match depends on the method

If-None-Match can also produce a failed condition, but the response depends on the request method. For GET or HEAD, a failed condition results in 304 Not Modified; for other methods, the server returns 412 Precondition Failed. This is one reason to record the method as well as the status code when diagnosing the response. RFC 9110 defines this distinction.

Rank #3
Sale
HTTP: The Definitive Guide
  • Used Book in Good Condition

How to diagnose and fix a 412

  1. Record the method and target. Note the full request method—such as GET, PUT, POST, or DELETE—and the resource URL. Conditional behavior can vary by method, so the status alone is not enough.
  2. Inspect the request headers. Check for If-Match, If-Unmodified-Since, and If-None-Match. If your application uses a client library or SDK, inspect the actual outgoing request rather than only the code that builds it; the library may add conditions.
  3. Check the response context. Save the response headers and body, including any API-specific error message. A service may explain its expected recovery workflow. For example, Cloudflare’s support page describes its 412 response and points readers to Cloudflare-specific ETag guidance: Cloudflare Error 412.
  4. Retrieve the latest representation and validator. Read the resource again and obtain its current ETag or modification date, if the service exposes one. Compare that value with the precondition your failed request sent. If the service does not expose the validator or its update process, consult that API’s documentation instead of guessing.
  5. Reconcile the change. Review what changed since your client’s copy was read. Reapply your intended edit to the latest representation or merge the competing changes. The correct resolution depends on the resource and API; replacing the whole resource with a stale copy can erase someone else’s work.
  6. Retry with the current condition. If the API expects conditional writes, send the updated validator with the retry. If a user or another process can edit the resource again before your retry, handle another conflict rather than assuming the refreshed value will remain current.

Do not treat deleting If-Match as a universal fix. It may make the request proceed without the safeguard that caught the conflict, allowing a stale update to overwrite newer work. Only change or omit a condition when the API’s documented behavior and your application’s conflict policy make that safe.

Why uploads and updates often trigger 412

An upload may be implemented as a conditional write, so it can fail for the same reason as an edit: the destination changed after the client checked it. The word “upload” does not identify the failed condition. Inspect the actual request, especially its conditional headers, and the service’s error body. If the operation is a retry, also check whether the original attempt succeeded but the client did not receive or process its response; repeating a write without understanding its state can create a separate problem.

Rank #4

For an update workflow, fetch the current resource and validator immediately before preparing the write, then use that validator in the conditional request if the service requires it. If the API supplies a specific conflict-resolution endpoint or procedure, follow that instead of assuming a generic GET-and-retry sequence applies.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

412 versus 304 Not Modified

Status Typical context Meaning
412 Precondition Failed A conditional request whose method is not GET or HEAD, such as a guarded update The condition was not met, so the requested method was not performed.
304 Not Modified Conditional GET or HEAD using If-None-Match The cached representation remains usable; the response is a cache-validation result, not a failed write.

In particular, a failed If-None-Match condition on GET or HEAD produces 304, while the same kind of failed condition on another method produces 412. Both arise from conditional requests, but they are not interchangeable. RFC 9110 specifies the method-dependent behavior.

Common troubleshooting mistakes

  • Refreshing but resending the old ETag. Make sure the retry uses the validator from the newly retrieved representation, not one cached in an earlier object or request.
  • Comparing ETags as if they were counters. ETags are opaque values. Test for the required match; do not assume that a tag that looks larger or newer has a particular meaning.
  • Removing every conditional header. First establish why the condition failed and whether bypassing it could overwrite newer data. Preserve concurrency protection when it is part of the service’s intended update model.
  • Assuming a date header and an ETag are interchangeable. They use different validators and comparison rules. Diagnose the condition actually sent and use the mechanism the API supports.
  • Retrying automatically without a conflict policy. A retry that simply repeats a stale body can reproduce the 412 or overwrite a later change if the guard is removed. Refresh and merge or reapply the intended change.
  • Ignoring service-specific behavior. Providers may return their own error details and prescribe a workflow. Use the relevant service documentation when the response does not explain how to obtain or submit the current validator.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server, not a tool for inspecting HTTP request headers or resolving 412 conflicts. If you need a visual record of what a URL rendered, it can capture a page; that is a separate task from diagnosing the failed precondition. One GET request can return an image or PDF, and the API accepts options for output and capture behavior. See the ScreenshotNeo API documentation.

Quick Recap

SaleBestseller No. 3
HTTP: The Definitive Guide
HTTP: The Definitive Guide
Used Book in Good Condition
$26.04
SaleBestseller No. 4
HTTP Pocket Reference: Hypertext Transfer Protocol
HTTP Pocket Reference: Hypertext Transfer Protocol
Used Book in Good Condition
$6.94
Bestseller No. 5
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie or consent banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response includes X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month, with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.