UnderHost
Knowledgebase Docs

HTTP 520 error-web server is down or unreachable

Fix CloudFlare 520 errors when origin server is down, unreachable, or timing out.

On this page

HTTP 520 "Unknown Error" is a CloudFlare-specific error that means CloudFlare cannot connect to your origin (web hosting) server. The origin server is down, unreachable, timing out, or blocking CloudFlare's requests. It's NOT a generic error—it only appears when CloudFlare is in front of your site.

Why is 520 CloudFlare-specific?

When you use CloudFlare, your visitors connect to CloudFlare's servers instead of directly to your hosting. CloudFlare then connects to your origin server (your web host) to fetch content. If that connection fails for any reason, CloudFlare returns a 520 error to the visitor.

Connection flow:

  • Visitor → CloudFlare → Your origin server
  • If the middle step fails, you get a 520
  • If CloudFlare can reach your origin but gets a 502 or 503 FROM the origin, you get that error code (not 520)

If you're NOT using CloudFlare, you won't see a 520 error—you might see 502, 503, or 504 instead.

Common causes of HTTP 520

CauseHow to identify
Origin server is downYou can't SSH in; hosting provider status page shows issues
Firewall blocking CloudFlare IPsServer is online, but firewall (UFW, CSF, etc.) blocks all CloudFlare traffic
Web server crashedNginx/Apache process is dead; systemctl status shows stopped
DNS misconfiguredCloudFlare can't resolve the origin server IP correctly
CloudFlare IP whitelistYou have a whitelist that excludes CloudFlare's IP ranges
Origin server unreachableNetwork issues, routing problems, or IP address changed
TimeoutOrigin takes >30 seconds to respond (too slow)

Diagnose the problem

Step 1: Test direct access (bypass CloudFlare)

To see if YOUR server is actually down or if it's a CloudFlare connection issue:

  1. Find your origin server IP (from your hosting control panel or welcome email)
  2. Modify your local hosts file to bypass CloudFlare:
    • Windows: C:\Windows\System32\drivers\etc\hosts
    • Mac/Linux: /etc/hosts
    • Add line: your.origin.ip yourdomain.com
  3. Try accessing http://yourdomain.com in your browser (not HTTPS, as the certificate won't match)

If you see your site: Your origin server is fine. The issue is CloudFlare → origin connectivity.

If you get an error: Your origin server is down.

Step 2: Check server status from command line

If you have SSH access to your VPS or dedicated server:

# Check if web server is running
sudo systemctl status nginx
sudo systemctl status apache2

# Check if server is responsive
sudo uptime

# Check system resources
free -h
df -h

Quick fixes (try in order)

  1. Wait 5 minutes: If your server is rebooting or restarting, 520 errors may resolve automatically
  2. Restart the web server: If you have VPS/dedicated access:
    sudo systemctl restart nginx
    # or for Apache:
    sudo systemctl restart apache2
  3. Check firewall status: Temporarily disable UFW or CSF to test:
    sudo ufw disable    # UFW firewall
    sudo csf -x         # CSF firewall

    If the site works with firewall disabled, CloudFlare IPs are blocked (see next section).

  4. Verify DNS: Ensure CloudFlare's DNS setup points to the correct origin server IP
  5. Check origin server IP in CloudFlare: Log into CloudFlare → DNS → Verify A record points to correct origin IP

Firewall blocking CloudFlare IPs

If your firewall (UFW, firewalld, CSF, or iptables) is blocking CloudFlare's IP ranges, CloudFlare can't connect to your origin.

To whitelist CloudFlare IPs:

For UFW:

# Add CloudFlare IP ranges (get latest from https://www.cloudflare.com/ips/)
sudo ufw allow from 173.245.48.0/20
sudo ufw allow from 103.21.244.0/22
# ... repeat for all CloudFlare IP ranges

For CSF (cPanel):

# Edit /etc/csf/csf.allow and add CloudFlare CIDR ranges
# Then reload:
sudo csf -r

For firewalld:

sudo firewall-cmd --permanent --add-source=173.245.48.0/20
sudo firewall-cmd --reload

CloudFlare publishes its IP ranges here: https://www.cloudflare.com/ips/

DNS misconfiguration

Verify CloudFlare's DNS setup:

  1. Log into CloudFlare
  2. Go to DNS tab
  3. Check the A record for your domain
  4. Ensure the IP address is your actual origin server IP (not a CloudFlare IP)
  5. Verify the record is set to DNS only (grey cloud) or proxied (orange cloud)

Test DNS resolution:

nslookup yourdomain.com
dig yourdomain.com @1.1.1.1

The result should show your origin server IP, not a CloudFlare IP.

When to contact your hosting provider

Contact UnderHost support if:

  • You've confirmed your server is down (can't SSH in, can't ping, services are stopped)
  • Restarting services didn't help
  • System resources are exhausted (no disk space, out of memory)
  • You see errors in system logs about disk/resource issues
  • You're on shared hosting and cannot access SSH or system tools

Provide to support:

  • Your domain name and server IP
  • When the 520 error started
  • Whether it's intermittent or constant
  • Any recent changes you made (CloudFlare config, firewall rules, etc.)
  • Error messages from your server logs (if accessible)
CloudFlare error vs origin server errors

520 = CloudFlare can't reach origin
502 from origin = Bad gateway (origin responded with error)
503 from origin = Service unavailable on origin
504 from origin = Origin took too long to respond

Related: 502 Bad Gateway | 503 Service Unavailable | 504 Gateway Timeout | CloudFlare setup guide

Was this article helpful?

Still troubleshooting?

Use UnderHost tools for quick checks, or open a support ticket when the issue needs account or server access.

Related articles

Back to Troubleshooting