Start free · Free tools · Fair usage limits
Browse Tools

Categories

Custom AI Solutions – AI2Flows
LIVE NEWS
Loading latest AI & SEO news…
Home›Tools›HTTP Status Codes Reference›HTTP 412 Precondition Failed
4xx Client Error

HTTP 412 Precondition Failed

HTTP 412 Precondition Failed means a condition the client set in a request header, such as If-Match or If-Unmodified-Since, was false on the server.

Quick answer

HTTP 412 Precondition Failed means a condition the client set in a request header, such as If-Match or If-Unmodified-Since, was false on the server. It is the standard way to stop lost updates: the edit is rejected because the resource changed since the client read it.

Last updated · Maintained by FreeAIToolz · How we test

What does HTTP 412 Precondition Failed mean?

A client reads a resource and its ETag, then sends an update with If-Match: "<etag>". If someone else changed the resource first, the ETag no longer matches and the server returns 412 instead of overwriting their changes.

Status code412
NamePrecondition Failed
Class4xx Client Error
Defined inRFC 9110 §15.5.13
Cacheable by defaultNo, unless Cache-Control says so
Safe to retry automatically?No: change the request first
Related headersIf-Match, If-Unmodified-Since, ETag

What causes HTTP 412?

  • The resource changed after the client fetched it (ETag mismatch).
  • An If-Unmodified-Since date that is older than the resource’s last change.

How do I fix HTTP 412?

  1. Return the current ETag so the client can re-sync.
  2. Use 428 Precondition Required if you want to force clients to send If-Match.

What should a client do after HTTP 412?

Re-fetch the resource, merge changes and retry with the new ETag.

Does HTTP 412 affect SEO?

No SEO impact.

Example 412 response

HTTP/1.1 412 Precondition Failed
Date: Mon, 01 Dec 2026 12:00:00 GMT
Content-Type: application/json

{"error":{"status":412,"message":"Precondition Failed"}}

How to return 412 Precondition Failed in code

Express (Node.js)

res.status(412).json({ error: 'Precondition Failed' });

Next.js route handler

return Response.json({ error: 'Precondition Failed' }, { status: 412 });

FastAPI (Python)

raise HTTPException(status_code=412, detail="Precondition Failed")

PHP

http_response_code(412);

Nginx

location = /example {
    return 412;
}

Other 4xx status codes

The request contains an error or cannot be fulfilled as sent. Fix the request before retrying.

Frequently asked questions

412 vs 409?
412 is specifically a failed request precondition header. 409 is a general state conflict without a precondition header.
How do ETags prevent lost updates?
The client sends If-Match with the ETag it read. The server only applies the update if that ETag is still current, otherwise it returns 412.
Is 412 a client or server error?
412 is in the 4xx class, so it is classed as a client error: the request needs to change before it can succeed.