412 Precondition Failed

A conditional header on the request evaluated to false, so the server did not perform the method.

Status

HTTP/1.1 412 Precondition Failed

Details

412 is how optimistic concurrency control fails safely. A client sends If-Match with the ETag it last saw, and if the resource has changed since then the server refuses the write instead of silently overwriting somebody else's update.

It also arises from If-Unmodified-Since and from If-None-Match on unsafe methods. The write did not happen, so no state changed: the client can re-read and try again.

Headers

Common causes

How to fix it

As the client

As the server

Examples

PUT /api/docs/91 HTTP/1.1
Host: api.example.com
If-Match: "v3"
Content-Type: application/json

{"title":"Updated"}

HTTP/1.1 412 Precondition Failed
ETag: "v5"

Specifications

RFC 9110 §15.5.13

See also