412 HTTP Origin: Network OSI layer 7 · Application Last updated 9 Oct 2026

HTTP 412 Precondition Failed

A conditional request header (If-Match, If-Unmodified-Since) didn’t match the current state of the resource.

Exact message you may see precondition failed
Seen on: REST API AWS Azure

Meaning

412 protects against lost updates: you sent If-Match: <etag> and someone else changed the resource since you read it. Object stores (S3, Azure Blob, GCS) and many REST APIs use it for optimistic concurrency.

Common causes

  • Resource modified by another client since your read (ETag changed)
  • Stale ETag cached by the client
  • Weak vs strong ETag mismatch (W/"...")
  • S3/Azure conditional writes (If-None-Match: * when the object already exists)

⚡ Quick fix

  1. Re-fetch the resource, re-apply your change, and retry with the new ETag
  2. Show users a “this item changed” message instead of overwriting
  3. Make sure proxies don’t rewrite ETags (gzip can turn strong ETags weak)

Detailed fix by platform

REST API

  1. Optimistic update loop:
    javascript
    async function update(id, change) {
      for (let attempt = 0; attempt < 3; attempt++) {
        const cur = await fetch(`/api/docs/${id}`);
        const etag = cur.headers.get('ETag');
        const doc = { ...(await cur.json()), ...change };
        const res = await fetch(`/api/docs/${id}`, { method: 'PUT', headers: { 'If-Match': etag, 'Content-Type': 'application/json' }, body: JSON.stringify(doc) });
        if (res.status !== 412) return res;
      }
      throw new Error('Document keeps changing — try again later');
    }

How to diagnose

  1. Condition — Which If-* header did you send?
  2. Current state — What is the current ETag/Last-Modified?
  3. Concurrency — Did another client write in between?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

1200 — Cloudflare Error 1200: Cache connection limit (Cloudflare)1200304 — HTTP 304 Not Modified (HTTP)30440001 — ERROR: could not serialize access due to concurrent update (PostgreSQL)40001409 — HTTP 409 Conflict (HTTP)409416 — HTTP 416 Range Not Satisfiable (HTTP)416A second operation was started on this context — EF Core: A second operation was started on this context instance before a previous operation completed (.NET)A second operation wa…all goroutines are asleep - deadlock — Go: fatal error: all goroutines are asleep - deadlock! (Go)all goroutines are as…AnotherOperationInProgress — Conflict: AnotherOperationInProgress — Another operation is in progress on the resource (Azure)AnotherOperationInPro…412

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.