HTTPfy

412 Precondition Failed

A precondition in the request headers (If-Match, If-Unmodified-Since, If-None-Match) was false.

412 at a glance

Code
412
Name
Precondition Failed
Class
4xx Client error
Status
IANA-registered standard code
Defined in
RFC 9110, Section 15.5.13
Cacheable by default
No by default. Caches store it only when the response carries explicit freshness (Cache-Control max-age, s-maxage or Expires).

What 412 means

412 Precondition Failed means the server evaluated a conditional header on a state-changing request and it did not hold. It is how optimistic concurrency works: "update only if the ETag is still X". If someone else changed the resource first, the update is rejected instead of silently overwriting their change.

What typically causes a 412

  • If-Match with an outdated ETag on PUT, PATCH or DELETE.
  • S3 conditional writes: If-None-Match: * on PutObject when the key already exists.
  • Azure Storage and Cosmos DB ETag checks; Google Cloud Storage ifGenerationMatch.
  • CouchDB and other document stores rejecting a stale revision.

Fix it on the server

  • Return the current ETag so the client can re-fetch and retry.

Fix it as a client or visitor

  • GET the resource again, re-apply your change to the new version, and retry with the new ETag.

Headers that go with 412

HeaderRole
If-MatchRequest precondition on the ETag.
If-Unmodified-SinceDate-based precondition.
ETagCurrent version.

Example response

HTTP/1.1 412 Precondition Failed
ETag: "v42"
Content-Type: application/json

{"error": "Resource was modified (current ETag v42)"}

Opens the HTTP headers tool with your URL filled in; it shows the status line and headers of every redirect hop.