520 Web Server Returned an Unknown Error
A Cloudflare-specific code: the origin returned something Cloudflare could not interpret as a valid HTTP response.
Cloudflare received an empty, unknown, or unexpected response from the origin server.
What HTTP 520 Web Server Returned an Unknown Error Means
Cloudflare received an empty, unknown, or unexpected response from the origin server.
A Cloudflare-specific code: the origin returned something Cloudflare could not interpret as a valid HTTP response.
Common Causes
- Origin server crashed or returned an empty response
- Connection reset by the origin
- Large headers or malformed response from the origin
- Origin killed the request (timeout, OOM)
How to Fix It (For Visitors)
- Refresh the page
- Try again in a few minutes
- Contact the website owner if it persists
How to Fix It (For Developers/Admins)
- Check origin server logs and error rates
- Ensure the origin returns valid HTTP responses
- Reduce response header size
- Confirm the web server (Nginx/Apache) is healthy
Returning a 520 Web Server Returned an Unknown Error (Code Examples)
If you build APIs or web apps, here is how to send an HTTP 520 response and how to test for it:
Node.js (Express)
app.get('/resource', (req, res) => {
res.status(520).json({ error: 'Web Server Returned an Unknown Error' });
});
Python (Flask)
@app.route('/resource')
def resource():
return jsonify(error='Web Server Returned an Unknown Error'), 520
PHP
<?php
http_response_code(520);
header('Content-Type: application/json');
echo json_encode(['error' => 'Web Server Returned an Unknown Error']);
Check the status with curl
curl -I https://example.com/resource
# Look for: HTTP/1.1 520 Web Server Returned an Unknown Error
Frequently Asked Questions
What does HTTP 520 Web Server Returned an Unknown Error mean?
A Cloudflare-specific code: the origin returned something Cloudflare could not interpret as a valid HTTP response. In short: Cloudflare received an empty, unknown, or unexpected response from the origin server.
Is a 520 Web Server Returned an Unknown Error error my fault or the website's?
520 is a 5xx server-error code, so the problem is on the server side, not your browser or device. As a visitor you can usually only retry; if you run the site, investigate the server.
How do I fix a 520 Web Server Returned an Unknown Error error?
Check origin server logs and error rates. Ensure the origin returns valid HTTP responses. Reduce response header size.
Official Specification
The 520 Web Server Returned an Unknown Error status code is defined in Cloudflare (non-standard).