Trang này chưa được dịch.

HTTP 412 Precondition Failed

A condition in the request headers (If-Match, If-Unmodified-Since) was not met.

Cập nhật

412
Precondition Failed
4xx Client error
Class
RFC 9110 §15.5.13
Defined in

What does HTTP 412 mean?

A condition in the request headers (If-Match, If-Unmodified-Since) was not met. Used for safe concurrent updates: the client sends the ETag it last saw, and the server rejects the update with 412 if the resource changed since then.

4xx Client error: The request has a problem the client can fix: wrong URL, missing credentials, bad data or too many requests.

How to fix 412 Precondition Failed

  • Re-fetch the resource and its current ETag, then retry.

412 and SEO

Not relevant for web pages.

Example response

HTTP/1.1 412 Precondition Failed

How to return a 412 response

Node.js (Express)

res.status(412).json({ error: 'Precondition Failed' });

PHP

http_response_code(412);

Python (Flask)

return {'error': 'Precondition Failed'}, 412

Go (net/http)

w.WriteHeader(412)

nginx

return 412;

Related status codes

Check which status code a URL returns with the HTTP header checker.

All HTTP status codesSearch the full list of status codes from 100 to 599 with their meanings and SEO impact.
Open the full list

Câu hỏi thường gặp

What does status code 412 mean?
412 Precondition Failed: A condition in the request headers (If-Match, If-Unmodified-Since) was not met.
How do I fix a 412 error?
Re-fetch the resource and its current ETag, then retry.
Does 412 affect SEO?
Not relevant for web pages.