Why does it happen?

There are several reasons for the 421 error, including:

  • Reusing a connection that was previously used to communicate with a different server.

  • Server configuration issues that prevent it from accepting requests from the current client.

  • Incorrect DNS configuration leading to requests being sent to the wrong server.

  • Load balancers or reverse proxies routing requests incorrectly within a network.

# Request example 
curl -X POST https://sandbox.oxylabs.io/ -H 'Accept: application/xml;q=0.9' -H 'Accept-Encoding: br' -H 'User-Agent: AppleWebKit/537.36'

Try Scraper API with 5K results

Common fixes

Methods you can try to remedy the error include:

  • Verify the server configuration to ensure it matches the intended target.

  • Avoid reusing server connections that may be misdirected.

  • Check the DNS settings to ensure requests are routed to the correct server.

  • Implement HTTP/2 server push with care to prevent misdirected requests.

# Response example 
HTTP/1.1 421 Misdirected Request
Content-Type: text/xml; charset=utf-8
Content-Length: 123



421
Misdirected Request

Forget HTTP errors with Scraper API

Web Scraper API

Self-Service

Public data delivery from the majority of websites

From

49

Useful resources

How to Rotate Proxies in Python Using Requests and AIOHTTP
How to Rotate Proxies in Python Using Requests and AIOHTTP
roberta avatar

Roberta Aukstikalnyte

2024-11-06

SOCKS vs HTTP Proxy
Choosing Between SOCKS vs HTTP Proxy
Vejune avatar

Vejune Tamuliunaite

2023-06-21

How to Send HTTP Headers With cURL
How to Send HTTP Headers With cURL
author avatar

Augustas Pelakauskas

2023-05-25

Get the latest news from data gathering world

I'm interested