HTTP Status Codes

HTTP 412 Precondition Failed

412
MediumWeb Server

Precondition Failed — one or more request header conditions evaluated to false on the server

What 412 Means

The 412 error on the HTTP Status Codes indicates precondition failed — one or more request header conditions evaluated to false on the server. This typically occurs due to if-match or if-unmodified-since header value does not match the current resource state.

412 is returned when the server validates conditional request headers and finds they do not match the current resource state, protecting against lost-update scenarios.

Technical Background

HTTP conditional requests allow clients to apply preconditions to their requests. A 412 is returned when at least one of those preconditions is false, preventing a potentially destructive update.

The resource was modified between when the client last read it and when it attempted to update it. The client must re-read the current state before retrying with updated conditional headers.

Common Causes

  • If-Match or If-Unmodified-Since header value does not match the current resource state
  • Optimistic concurrency control preventing an overwrite of a concurrently modified resource
  • Conditional PUT request targeting a resource version that has since changed

Typical Scenarios

  • REST API client performing an optimistic-lock update where the resource was modified by another client first
  • CDN applying If-Unmodified-Since logic to a cache validation request
  • Version-controlled document system rejecting an edit to a stale resource copy

What to Know

A 412 is a safety mechanism protecting against lost updates, not a server failure. The request was structurally valid — the precondition was not satisfied by the current resource state. This error signals a concurrency conflict rather than a protocol error.

Frequently Asked Questions

Common questions about HTTP 412 error

412 is returned when a conditional header (If-Match, If-Unmodified-Since) fails. 409 is a more general conflict when the request body itself conflicts with the resource state.

Related Error Codes