HTTP

HTTP 412 Precondition Failed vs 421 Misdirected Request

Both HTTP 412 (Precondition Failed) and 421 (Misdirected Request) belong to the 4xx Client Error category. 412 indicates that one or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false. Meanwhile, 421 means that the request was directed at a server that is unable to produce a response for the combination of scheme and authority in the URI.

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

The request was directed at a server that is unable to produce a response for the combination of scheme and authority in the URI.

When You See It

With HTTP/2 when a connection is reused for a domain the certificate doesn't cover.

How to Fix

Retry the request on a new connection.

Key Differences

1.

HTTP 412: One or more conditions in the request headers (If-Match, If-Unmodified-Since) evaluated to false.

2.

HTTP 421: The request was directed at a server that is unable to produce a response for the combination of scheme and authority in the URI.

3.

You encounter 412 when when using conditional requests with ETags and the resource has changed.

4.

You encounter 421 when with HTTP/2 when a connection is reused for a domain the certificate doesn't cover.

When to Use Which

For 412 (Precondition Failed): Refresh the ETag/Last-Modified value and retry with updated preconditions. For 421 (Misdirected Request): Retry the request on a new connection.

Learn More