HTTP 504 Gateway Timeout vs 521 Web Server Is Down
Both HTTP 504 (Gateway Timeout) and 521 (Web Server Is Down) belong to the 5xx Server Error category. 504 indicates that the server, acting as a gateway or proxy, did not receive a timely response from the upstream server. Meanwhile, 521 means that cloudflare-specific. The origin server refused the connection.
Description
The server, acting as a gateway or proxy, did not receive a timely response from the upstream server.
When You See It
When an upstream server is too slow to respond within the proxy's timeout window.
How to Fix
Increase proxy timeout settings. Optimize upstream server performance. Check for long-running queries.
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
HTTP 504: The server, acting as a gateway or proxy, did not receive a timely response from the upstream server.
HTTP 521: Cloudflare-specific. The origin server refused the connection.
You encounter 504 when when an upstream server is too slow to respond within the proxy's timeout window.
You encounter 521 when when Cloudflare can't establish a TCP connection to the origin server.
When to Use Which
For 504 (Gateway Timeout): Increase proxy timeout settings. Optimize upstream server performance. Check for long-running queries. For 521 (Web Server Is Down): Check that the origin server is running and the firewall allows Cloudflare IPs.