Skip to main content
4xx Client Error

421 Misdirected Request

The request was directed at a server that is not configured to produce a response.

Meaning & Description

The 421 Misdirected Request status code indicates that the request was directed at a server that is not configured to produce a response for the request. This can occur when a connection is reused (e.g., in HTTP/2) or when a TLS certificate contains a wildcard or multiple Subject Alternative Names (SANs) that resolve to a server that cannot actually handle the specific domain requested.

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

  1. 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.
  2. Verify that your load balancer or reverse proxy is sending the correct `Host` header to the backend.
  3. 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
HTTP/2 421 Misdirected Request
Content-Type: text/plain

Server not configured for this domain.
Node.js (Express)
app.use((req, res, next) => {
  const allowedHosts = ["api.example.com"];
  if (!allowedHosts.includes(req.hostname)) {
    return res.status(421).send("Misdirected Request");
  }
  next();
});
Python (FastAPI)
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)
Go (net/http)
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)
}
C# (ASP.NET Core)
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);
    }
}
cURL
# Passing a Host header the server does not recognize
curl -H "Host: unknown.com" https://api.example.com

Raw HTTP Response Example

HTTP Response
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

Cloudflare: May return 421 if a request is routed to an edge node that does not have the configuration for the requested domain.
Nginx: Can be configured to return 421 for a default server block to catch and reject requests with unrecognized Host headers.

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."