HTTP

HTTP 400 Bad Request vs 521 Web Server Is Down

HTTP 400 (Bad Request) is a 4xx Client Error response, while 521 (Web Server Is Down) is a 5xx Server Error response. 400 indicates that the server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing. In contrast, 521 means that cloudflare-specific. The origin server refused the connection.

Description

The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.

When You See It

When sending malformed JSON, missing required fields, or invalid query parameters.

How to Fix

Check the request body format, validate all required fields, and ensure proper encoding.

Description

Cloudflare-specific. The origin server refused the connection.

When You See It

When Cloudflare can't establish a TCP connection to the origin server.

How to Fix

Check that the origin server is running and the firewall allows Cloudflare IPs.

Key Differences

1.

400 is a 4xx Client Error response, while 521 is a 5xx Server Error response.

2.

HTTP 400: The server cannot process the request due to malformed syntax, invalid request message framing, or deceptive request routing.

3.

HTTP 521: Cloudflare-specific. The origin server refused the connection.

4.

You encounter 400 when when sending malformed JSON, missing required fields, or invalid query parameters.

5.

You encounter 521 when when Cloudflare can't establish a TCP connection to the origin server.

When to Use Which

For 400 (Bad Request): Check the request body format, validate all required fields, and ensure proper encoding. For 521 (Web Server Is Down): Check that the origin server is running and the firewall allows Cloudflare IPs.

Learn More