Learn why Cloudflare Error 522 occurs and how to fix it. Step-by-step solutions for both website visitors and website owners
What is Cloudflare Error 522?
Error 522 Connection Timed Out happens when Cloudflare connects to your server but the server doesn’t respond in time.
It usually looks like this:
“The initial connection between Cloudflare’s network and the origin web server timed out.”
Causes of Error 522
- Server is offline or overloaded
- Firewall or security software is blocking Cloudflare
- Wrong server IP in Cloudflare DNS settings
- Web server is not accepting requests on ports 80/443
- High latency between Cloudflare and origin server
Fix for Website Visitors
As a visitor, there’s not much you can do. You can:
- Refresh the page after a few minutes
- Try accessing the site from another device or network
- Contact the site owner if the issue persists
Fix for Website Owners
✅ Step 1: Check if Your Server is Online
SSH into your server and verify it’s running:
uptime
systemctl status nginx
Make sure your web server (Nginx/Apache) is active.
✅ Step 2: Verify Firewall Rules
Cloudflare uses a list of IP ranges. You must allow them through your firewall.
For UFW (Ubuntu):
sudo ufw allow proto tcp from 173.245.48.0/20 to any port 80,443
sudo ufw allow proto tcp from 103.21.244.0/22 to any port 80,443
# (repeat for all Cloudflare IP ranges)
You can find the full list here: Cloudflare IPs
✅ Step 3: Check Web Server Configuration
Make sure your server is listening on port 80 and 443:
ss -tulpen | grep ':80\|:443'
If not, adjust your Nginx/Apache configuration.
✅ Step 4: Verify Cloudflare DNS Settings
In your Cloudflare dashboard → DNS tab, ensure your domain’s DNS records point to the correct server IP.
Example:
A
record → your server’s public IPCNAME
record (optional)
✅ Step 5: Reduce Server Load
If your server is overloaded, consider:
- Upgrading CPU/RAM
- Using caching (e.g., Redis, Varnish, WordPress caching plugins)
- Offloading static content to a CDN
⚡ Quick Recap
- Visitors: Wait, refresh, or contact the site owner.
- Site Owners: Check server health, firewall rules, ports, and DNS records.
✅ By following these steps, you can resolve Cloudflare Error 522 and keep your site available worldwide.