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/412412 vs similar status codes
Frequently Asked Questions
What does HTTP Status 412 mean?
Why am I getting a 412 status code?
How do I fix a 412 Precondition Failed error?
What is the difference between 412 Precondition Failed and 428 Precondition Required?
How can I test how my app handles a 412 response?
Other 4xx status codes
Browse the full HTTP status codes directory or troubleshoot terminal errors in the Error Fix Encyclopedia.