HTTP 412 Precondition Failed vs 521 Web Server Is Down
HTTP 412 (Precondition Failed) is a 4xx Client Error response, while 521 (Web Server Is Down) is a 5xx Server Error response. 412 indicates that one or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false. In contrast, 521 means that cloudflare-specific. The origin server refused the connection.
Description
One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
When You See It
When using conditional requests with ETags and the resource has changed.
How to Fix
Refresh the ETag/Last-Modified value and retry with updated preconditions.
Description
Cloudflare-specific. The origin server refused the connection.
When You See It
When Cloudflare can't establish a TCP connection to the origin server.
How to Fix
Check that the origin server is running and the firewall allows Cloudflare IPs.
Key Differences
412 is a 4xx Client Error response, while 521 is a 5xx Server Error response.
HTTP 412: One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.
HTTP 521: Cloudflare-specific. The origin server refused the connection.
You encounter 412 when when using conditional requests with ETags and the resource has changed.
You encounter 521 when when Cloudflare can't establish a TCP connection to the origin server.
When to Use Which
For 412 (Precondition Failed): Refresh the ETag/Last-Modified value and retry with updated preconditions. For 521 (Web Server Is Down): Check that the origin server is running and the firewall allows Cloudflare IPs.