
HTTP 412 Precondition Failed is a client error response that means the server does not meet one or more preconditions the client specified in its request headers. It belongs to the 4xx class, so the problem originates on the client side rather than the server. The server is rejecting the request because a condition the client set was not satisfied.
A server returns 412 when a request includes conditional headers such as If-Match, If-None-Match, If-Unmodified-Since, or If-Modified-Since, and the condition those headers express is not met. This typically happens on state-changing methods like PUT or DELETE — not on GET or HEAD requests. For example, if a client sends an If-Match header with a stored ETag and the resource has since been updated, the ETag no longer matches and the server responds with 412.
First, re-fetch the resource to get its current state and the latest ETag or modification timestamp from the response headers. Then reapply your changes and include the updated ETag in the If-Match header before retrying the request. If you are seeing 412 unexpectedly, check whether your client is sending conditional headers it does not need and remove them.
HTTP 412 means the client did send a precondition header but the condition was not satisfied. HTTP 428 Precondition Required means the server requires a precondition header and the client did not include one at all. In short, 412 is about a failed condition and 428 is about a missing condition.
HTTP 304 Not Modified is returned on conditional GET or HEAD requests when the resource has not changed, telling the client it can use its cached copy. HTTP 412 is returned on modification requests (PUT, DELETE) when a condition such as If-Match or If-Unmodified-Since fails, preventing the update from proceeding. They both involve conditional headers but serve opposite purposes in different contexts.
The most common use case is preventing concurrent edit conflicts, sometimes called a mid-air collision. A server includes an ETag in its response when delivering a resource. When a client later tries to update that resource, it sends the stored ETag in an If-Match header. If another client has already modified the resource in the meantime, the ETag no longer matches and the server returns 412, protecting data integrity by refusing the stale update.