421 Misdirected Request
The request was directed at a server that is not configured to produce a response.
Meaning & Description
Common Causes
- A shared TLS certificate covering both `a.example.com` and `b.example.com`, but the server for `a` cannot serve `b`. The browser reuses the connection for `b`, resulting in a 421.
- Misconfigured load balancers sending traffic to a backend pool that lacks the proper virtual host definition.
- DNS points to the correct IP, but the web server (like Nginx or Apache) does not have a `server_name` or `VirtualHost` matching the request.
How to fix a 421 error
- Check your TLS certificates. If you use wildcard certs, ensure the backend server receiving the traffic can actually serve all subdomains, or disable connection coalescing.
- Verify that your load balancer or reverse proxy is sending the correct `Host` header to the backend.
- Check the `server_name` (Nginx) or `ServerName` (Apache) directives in your web server configuration.
Browser & SEO Behaviour
Browser Behavior
Modern browsers will automatically retry the request over a new connection if they receive a 421 on an HTTP/2 or HTTP/3 reused connection.
SEO Impact
If Googlebot receives a 421, it may drop the connection and mark the crawl as a failure. Ensure your server correctly handles the domains you want indexed.
CDN Behavior
CDNs will rarely return a 421 unless specifically instructed by the origin or if the CDN edge node itself receives a request it cannot route.
Code Examples
HTTP/2 421 Misdirected Request
Content-Type: text/plain
Server not configured for this domain.app.use((req, res, next) => {
const allowedHosts = ["api.example.com"];
if (!allowedHosts.includes(req.hostname)) {
return res.status(421).send("Misdirected Request");
}
next();
});from fastapi import FastAPI, Request, HTTPException
app = FastAPI()
@app.middleware("http")
async def verify_host(request: Request, call_next):
if request.url.hostname != "api.example.com":
from fastapi.responses import PlainTextResponse
return PlainTextResponse("Misdirected Request", status_code=421)
return await call_next(request)func handler(w http.ResponseWriter, r *http.Request) {
if r.Host != "api.example.com" {
http.Error(w, "Misdirected Request", 421)
return
}
w.WriteHeader(http.StatusOK)
}public class HostFilteringMiddleware
{
private readonly RequestDelegate _next;
public HostFilteringMiddleware(RequestDelegate next) => _next = next;
public async Task Invoke(HttpContext context)
{
if (context.Request.Host.Host != "api.example.com")
{
context.Response.StatusCode = 421;
await context.Response.WriteAsync("Misdirected Request");
return;
}
await _next(context);
}
}# Passing a Host header the server does not recognize
curl -H "Host: unknown.com" https://api.example.comRaw HTTP Response Example
HTTP/2 421 Misdirected Request
Date: Wed, 21 Oct 2026 07:28:00 GMT
Content-Type: text/plain
Server is not authoritative for this domain.Real-world Examples
Frequently Asked Questions
Why did my HTTP/2 connection cause a 421 error?
In HTTP/2, browsers try to reuse connections for performance. If domains A and B share an IP and a TLS certificate, the browser might send a request for domain B over domain A's connection. If server A doesn't know how to handle B, it returns 421, prompting the browser to open a new connection for B.
Is a 421 error a client or server issue?
It is technically a client error (4xx) because the client sent the request to the wrong authoritative server. However, it is almost always caused by complex DNS, TLS, or proxy configurations on the server side.
How do I stop getting 421 errors behind a load balancer?
Ensure your load balancer is forwarding the correct `Host` header (using directives like `ProxyPreserveHost` in Apache or `proxy_set_header Host $host;` in Nginx).
Did You Know?
The 421 status code was introduced specifically to handle edge cases created by HTTP/2's aggressive connection coalescing features.
Developer Tips
- If you are hosting multiple microservices behind a single wildcard TLS certificate, ensure your ingress controller correctly routes traffic, or use 421 to force clients to split their connections.
- Always use a default "catch-all" virtual host block in your web server that returns a 421 (or 444 in Nginx) to drop traffic for unrecognized domains.
Interview Questions
These are questions you might face in a backend or API design interview that touch on HTTP 421.
What does the 421 Misdirected Request code do in the context of HTTP/2?
It tells the client that the server it reached (via a reused connection due to connection coalescing) is not authoritative for the requested domain. The client will then gracefully close the reused connection and open a new one directly to the proper server.
Common Interview Mistakes
- Confusing 421 with a 301/302 Redirect. 421 doesn't tell the client *where* to go; it just tells the client "you can't get it from me on this connection."