HTTP

HTTP 429 Too Many Requests vs 521 Web Server Is Down

HTTP 429 (Too Many Requests) is a 4xx Client Error response, while 521 (Web Server Is Down) is a 5xx Server Error response. 429 indicates that the user has sent too many requests in a given time (rate limiting). The response should include a Retry-After header. In contrast, 521 means that cloudflare-specific. The origin server refused the connection.

Description

The user has sent too many requests in a given time (rate limiting). The response should include a Retry-After header.

When You See It

When hitting API rate limits or making too many requests too quickly.

How to Fix

Check the Retry-After header. Implement exponential backoff. Consider caching responses.

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.

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

2.

HTTP 429: The user has sent too many requests in a given time (rate limiting). The response should include a Retry-After header.

3.

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

4.

You encounter 429 when when hitting API rate limits or making too many requests too quickly.

5.

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

When to Use Which

For 429 (Too Many Requests): Check the Retry-After header. Implement exponential backoff. Consider caching responses. For 521 (Web Server Is Down): Check that the origin server is running and the firewall allows Cloudflare IPs.

Learn More