421
HTTP 421 Misdirected Request
4xx Client Error
4xx Client Error
RFC 7540, Section 9.1.2
What is HTTP 421 Misdirected Request?
The 421 (Misdirected Request) status code indicates that the request was directed at a server that is not able to produce a response. This can occur when a connection is reused for a different origin in HTTP/2 or when a server receives a request for a virtual host it does not serve.
Common Use Cases
- HTTP/2 connection reuse for different origins
- Load balancer routing errors
- Misconfigured virtual hosts
Usage Example
When using HTTP/2 connection pooling, a client might reuse a connection to one virtual host to send a request intended for another. The server detects this misdirection and responds with 421, prompting the client to open a new connection for the correct host.
# Nginx - handling misdirected requests
server {
listen 443 ssl http2;
server_name example.com;
if ($host != 'example.com') {
return 421;
}
}