← Back to Chapters

HTTP 421 – Misdirected Request

? HTTP 421 – Misdirected Request

? Quick Overview

HTTP 421 Misdirected Request indicates that the server received a request that was directed to the wrong origin or virtual host. This status code is commonly associated with HTTP/2 and HTTP/3 connections where multiple domains share the same connection.

? Key Concepts

  • Occurs when a request is sent to a server that cannot produce a valid response
  • Often related to incorrect Host headers
  • Seen in reverse proxy and load balancer setups
  • Introduced to prevent serving content for the wrong domain

? Syntax / Theory

A 421 response tells the client that the request should be retried on a different connection. The server intentionally rejects the request to avoid security or routing issues.

? Code Example(s)

? View HTTP Protocol Example
// Example of a 421 response sent by a server
HTTP/2 421
content-type: text/plain

Misdirected Request
? View Node.js Example
// Node.js Express example sending a 421 status
res.status(421).send("Misdirected Request");

? Live Output / Explanation

What Happens?

The browser or client receives a 421 response and understands that the request was sent to the wrong server endpoint. Modern clients may automatically retry the request using a new connection.

? Interactive Example / Simulation

Change the host and click send to see what happens.

? Use Cases

  • HTTP/2 and HTTP/3 multi-domain connections
  • Reverse proxies like Nginx or Envoy
  • CDNs handling multiple hostnames
  • Microservices behind a gateway

✅ Tips & Best Practices

  • Ensure correct Host headers in requests
  • Configure proxies to route domains properly
  • Use separate connections for unrelated domains
  • Monitor server logs for frequent 421 errors

? Try It Yourself

  • Simulate a wrong Host header using curl
  • Configure a reverse proxy with multiple domains
  • Test HTTP/2 behavior using browser dev tools