HTTP 412 Precondition Failed
Updated Free mock REST & WebSocket APIs
HTTP 412 Precondition Failed — A condition in the request headers (If-Match, If-Unmodified-Since…) evaluated to false.
- Class
- 4xx Client Error
- Defined in
- RFC 9110 §15.5.13
- Official
- Yes (IANA registry)
- Cacheable by default
- No (unless Cache-Control/Expires say so)
- Safe to retry
- Not without changing the request
Try it: get a real 412 response
Our test endpoint answers every request with 412 Precondition Failed.
curl -i https://mockfox.dev/api/status/412Use it in tests, health-check monitors or to see how your client handles a 412. Add ?delay=2000 to slow it down.
What does HTTP 412 mean?
Used for optimistic concurrency: a client sends If-Match: "v7" with a PUT, and if the resource has since changed to v8 the server answers 412 rather than overwriting someone else's edit. The client should re-fetch, merge and retry. Amazon S3 returns it for failed conditional writes too.
How to fix 412
- Visitors: Reload the page, check the address for typos, and clear the site's cookies. If it persists, the site owner needs to fix it.
- Developers: Read the response body and server logs for details, fix the request (method, headers, body, credentials) and return a clear error message to clients.
Example 412 response
HTTP/1.1 412 Precondition Failed
ETag: "v8"
Content-Type: application/json
{"status":412,"error":"Precondition Failed"}4xx Client Error: The request contains an error or can't be fulfilled — fix the request before retrying. See the full list of HTTP status codes.
Related status codes
- 428 Precondition RequiredThe server requires the request to be conditional (If-Match etc.) to prevent lost updates.
- 409 ConflictThe request conflicts with the current state of the resource.
- 304 Not ModifiedThe cached copy the client already has is still valid, so no body is sent.
Related tools
Frequently asked questions
What does HTTP 412 Precondition Failed mean?
A condition in the request headers (If-Match, If-Unmodified-Since…) evaluated to false.
Is 412 a client or a server error?
412 is a 4xx code, so it signals a problem with the request (as seen by the server). Retrying the identical request usually gives the same result.
Where is 412 defined?
In RFC 9110 §15.5.13. It's listed in the IANA HTTP Status Code Registry.
How can I test how my app handles a 412?
Call https://mockfox.dev/api/status/412 — it responds with 412 to any method, with CORS enabled. Add ?delay=2000 to simulate a slow response.