421 Misdirected Request
Description
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 in various scenarios, but it's most commonly associated with HTTP/2 and HTTP/3 connections where a client might send a request to a server that is not authoritative for the requested resource.
This status code is commonly used when: - A client sends a request to a server using an incorrect connection for the target host - A client sends a request through a proxy that connects to the wrong origin server - A load balancer or gateway routes a request to a server that cannot handle it - A request is sent to a server in a cluster that is not responsible for the requested resource
The 421 Misdirected Request
status was introduced in HTTP/2 (RFC 7540) to address specific connection management issues that can arise in multiplexed connection environments.
Syntax
The server responds with a 421 Misdirected Request
status:
HTTP/1.1 421 Misdirected Request
Content-Type: application/json
Content-Length: [length in bytes]
{
"error": "Misdirected Request",
"message": "The request was directed at a server that is not able to produce a response"
}
Examples
HTTP/2 Connection Reuse Example
A client reuses an HTTP/2 connection for a different authority than what the connection was established for:
Client Request:
(Note: This is HTTP/2 frame format, not the traditional HTTP/1.1 text format)
Server Response:
:status = 421
content-type = application/json
content-length = 187
{
"error": "Misdirected Request",
"message": "This connection was established for service-a.example.com, not service-b.example.com",
"correct_authority": "service-a.example.com"
}
Load Balancer Routing Example
A client sends a request that a load balancer routes to a server that isn't configured to handle it:
Client Request:
GET /api/user-profile HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Server Response:
HTTP/1.1 421 Misdirected Request
Content-Type: application/json
Content-Length: 215
{
"error": "Misdirected Request",
"message": "This server is not configured to handle user profile requests",
"request_id": "req-12345",
"server_id": "api-server-42"
}
Microservice Architecture Example
A client sends a request to a microservice that isn't responsible for the requested resource:
Client Request:
POST /orders/123/process-payment HTTP/1.1
Host: services.example.com
Content-Type: application/json
Content-Length: 145
{
"payment_method": "credit_card",
"card_token": "tok_visa_4242",
"amount": 99.99,
"currency": "USD"
}
Server Response:
HTTP/1.1 421 Misdirected Request
Content-Type: application/json
Content-Length: 243
{
"error": "Misdirected Request",
"message": "This service handles order management, not payment processing",
"correct_service": "payment-service.example.com",
"correlation_id": "corr-67890"
}
Summary
The 421 Misdirected Request
status code is particularly valuable in modern web architectures that use HTTP/2, microservices, service meshes, and complex routing systems. It provides a clear signal that the client's request reached a server that is not the correct destination for that particular request. This helps clients understand that they need to direct their request elsewhere, potentially by establishing a new connection or using a different authority. The status code improves efficiency by quickly identifying routing issues rather than having servers attempt to process requests they're not designed to handle.