Knowledgebase

How to fix Cloudflare errors 520, 521, 522, 524 and 525

When Cloudflare cannot get a good answer from your hosting server, it shows its own error page with a number. This guide explains how to fix Cloudflare errors 520, 521, 522, 524 and 525, what each one means and what you can check yourself before contacting support.

First: which side is the problem?

The Cloudflare error page shows three boxes: your browser, Cloudflare and the host. The box marked "Error" tells you where the problem is. For all the errors below, Cloudflare is working; the problem is between Cloudflare and your hosting server (the "origin").

Quick reference

ErrorMeaningMost common cause
520The server returned an empty or unexpected responsePHP crash, very large headers or cookies, server resetting the connection
521Web server is down / refused the connectionWeb server stopped, or the firewall is blocking Cloudflare IPs
522Connection timed outWrong IP in DNS, server overloaded, or packets dropped by a firewall
524The server took too long to answerA slow script, import or report taking longer than about 100 seconds
525SSL handshake failedSSL mode is Full/Full (strict) but the server has no working SSL for the domain

Step 1: Check the IP in Cloudflare DNS

  1. In the Cloudflare dashboard, open DNS > Records.
  2. Check that the A records for the root domain and www point to your current hosting IP. You can find the IP in cPanel (right sidebar, Shared IP Address or Dedicated IP Address).
  3. If you recently moved hosting, this is the most common cause of 521 and 522.

Step 2: Test the server without Cloudflare

In the domain overview, use Pause Cloudflare on Site (under advanced actions), wait a few minutes, and open the site. If it still fails, the problem is on the hosting server; if it works, the problem is the connection between Cloudflare and the server. Unpause when you finish testing.

Step 3: Fixes by error

  • 520: check cPanel Errors and your site's error_log for PHP fatal errors. Disable recently added plugins. Clear cookies; very large cookies can trigger 520. See fixing a 500 error for PHP debugging.
  • 521: the server refused Cloudflare. On EgWeb servers Cloudflare IP ranges should be allowed. If you get 521 on our hosting, open a ticket with the domain and time so we check the firewall and web server.
  • 522: check the IP (Step 1). If correct, the server may be overloaded or blocking. Tell us the time it happened.
  • 524: a request took too long. Find which page or action triggers it (often an import, backup or report). Run long tasks from cron or through a subdomain that is not proxied (grey cloud), or optimize the script.
  • 525: run AutoSSL in cPanel SSL/TLS Status so the domain has a valid certificate, or install a Cloudflare Origin Certificate. If you see 526, the certificate is invalid or expired. See Cloudflare SSL modes.
Tip: When you contact support, send the Ray ID shown at the bottom of the Cloudflare error page, the exact time and the URL. It makes finding the cause much faster.

Common problems

  • Error only on some pages: usually 520 or 524 from a specific script. Check the error log for that page.
  • Error appeared after changing SSL settings: 525 or 526. Go back to Full (strict) with a valid certificate.
  • Error only on cPanel or webmail links: set those DNS records to DNS only (grey cloud).

Frequently asked questions

Is Cloudflare down when I see these errors?

Almost never. The error page itself comes from Cloudflare, which means Cloudflare is up; it could not reach your server properly.

Can I just turn Cloudflare off?

Pausing Cloudflare is a good test, but fix the cause so you keep the protection and caching. Review your setup with how to add your website to Cloudflare.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • cloudflare, error 520, error 521, error 522, error 525, error 526, troubleshooting

Was this answer helpful?

0 Users Found This Useful