HTTP

HTTP 421 Misdirected Request vs 428 Precondition Required

Both HTTP 421 (Misdirected Request) and 428 (Precondition Required) belong to the 4xx Client Error category. 421 indicates 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. Meanwhile, 428 means that the server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.

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.

Description

The server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.

When You See It

When an API requires optimistic concurrency control via ETags.

How to Fix

Fetch the resource first to get its ETag, then include If-Match in your update request.

Key Differences

1.

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.

2.

HTTP 428: The server requires the request to be conditional (e.g., include If-Match header) to prevent lost updates.

3.

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

4.

You encounter 428 when when an API requires optimistic concurrency control via ETags.

When to Use Which

For 421 (Misdirected Request): Retry the request on a new connection. For 428 (Precondition Required): Fetch the resource first to get its ETag, then include If-Match in your update request.

Learn More