Skip to main content
HTTP/4xx (Client Error)

412 Precondition Failed

One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.

❓ Why does this happen?

Optimistic concurrency control: the resource ETag changed because another client updated it first.

✅ How to fix it

Re-fetch the resource to obtain the latest ETag, merge changes, then retry with the new If-Match value.

Return or handle 412 in your stack

// app/api/resource/route.ts
export function GET() {
  return Response.json(
    { error: "Precondition Failed", status: 412 },
    {
      status: 412
    }
  );
}

Live 412 mock endpoint

Point your app, tests, or retry logic at this free public URL to reproduce a real 412 response (CORS enabled, optional ?delay=ms up to 5000).

https://castov.com/api/mock/412

412 vs similar status codes

Frequently Asked Questions

What does HTTP Status 412 mean?
One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
Why am I getting a 412 status code?
Optimistic concurrency control: the resource ETag changed because another client updated it first.
How do I fix a 412 Precondition Failed error?
Re-fetch the resource to obtain the latest ETag, merge changes, then retry with the new If-Match value.
What is the difference between 412 Precondition Failed and 428 Precondition Required?
412 means a conditional header (If-Match) did not match. 428 means the server requires a conditional header and none was sent.
How can I test how my app handles a 412 response?
Send a request to https://castov.com/api/mock/412 — it returns a real 412 Precondition Failed response with CORS enabled. Add ?delay=2000 to simulate a slow server.

Other 4xx status codes

Browse the full HTTP status codes directory or troubleshoot terminal errors in the Error Fix Encyclopedia.