421 Misdirected Request: Wrong Server or Virtual Host
Common Causes of 421 Errors
| Cause | Example | How to Fix |
|---|---|---|
| Virtual host mismatch | Server hosts example.com, client requests subdomain.example.org. | Ensure the client uses the correct hostname that the server serves. |
| SSL/TLS certificate not covering the hostname | Certificate is for *.example.com, but client requests example.org. | Obtain a certificate that covers the requested hostname. |
| HTTP/2 connection reuse | Client reuses an HTTP/2 connection for a different origin server. | Use separate connections for each origin, or ensure the server supports the alternate hostname. |
| Server misconfiguration | Server has multiple virtual hosts but the default or requested host is not configured. | Check the server configuration and add the missing virtual host. |
| DNS or load balancer issues | Client resolves a hostname to an IP that belongs to a different server. | Correct DNS records or load balancer routing. |
Example: 421 Response
A client connects to a server using HTTP/2 and requests a hostname that the server does not serve:
How to Fix 421 Errors
- If you're a client developer: Ensure you are sending the correct
Hostheader (or:authoritypseudo‑header in HTTP/2) that matches a domain the server is configured to serve. If you are reusing a connection, make sure the new request is for the same origin (scheme+host+port) as the original connection. - If you're a server administrator: Verify that your virtual host configuration includes all domains you intend to serve. Check that your SSL/TLS certificate covers all domains (or use a wildcard certificate). For HTTP/2, ensure the server sends the
ORIGINorAlt-Svcheaders to inform clients of supported origins. - If you're an end‑user: This error is rare and usually indicates a misconfigured website. Try refreshing the page, using a different browser, or contacting the site administrator.
421 in the Context of HTTP/2
HTTP/2 allows multiplexing multiple requests over a single connection. However, each connection is tied to a specific origin (scheme + host + port). If a client tries to reuse a connection for a different origin, the server may return 421 to indicate that the connection is misdirected. The client should then open a new connection to the correct origin.
This is similar to the concept of "connection coalescing" in HTTP/2, where multiple origins with the same IP and certificate can be served over one connection. If the certificate does not cover the requested origin, 421 is the correct response.
When to Use 421
- When the server cannot serve the requested hostname – either because it's not configured or the certificate does not cover it.
- When a client attempts connection reuse for a different origin – to prevent cross‑origin contamination.
Frequently Asked Questions
Is 421 a client error or a server error?
It's a client error (4xx) because the client directed the request to the wrong server or virtual host. However, the server's configuration also plays a role, as it must clearly indicate which origins it supports.
Can I see 421 in a browser?
It's rare, but possible if a website's SSL certificate does not cover all subdomains, or if a CDN is misconfigured. Most modern browsers handle this by falling back to a new connection rather than showing the error.
Is 421 related to HTTP/3?
Yes, HTTP/3 also uses the concept of origins and connections. The same principles apply; 421 can be used in HTTP/3 to indicate a misdirected request as well.