Error 522 Connection Timed Out: Causes, Fixes & Prevention

Last tested: October 22, 2026 · By Alex

Error 522 Connection Timed Out means a CDN could reach your network but did not receive a response from the origin server in time. The connection starts successfully, then stalls.

This is usually caused by overloaded servers, blocked requests, or network routing problems. Fixing it quickly is critical because prolonged timeouts can impact rankings, user trust, and revenue.


⚡ Quick Fix

  • Check if your origin server is online.
  • Restart web services (Apache, Nginx, PHP-FPM).
  • Whitelist CDN IP ranges in your firewall.
  • Reduce server load or upgrade hosting.
  • Investigate slow database queries.
  • Contact your hosting provider if timeouts continue.

Most Error 522 incidents trace back to server response delays.


What Is Error 522?

Error 522 occurs when a TCP connection between the CDN and your origin server is established, but the server fails to respond before the timeout threshold.

In simple terms — the server is reachable but too slow.

Connection sequence:

  • Visitor → CDN → Origin server
  • Handshake succeeds
  • Server does not respond fast enough
  • Timeout triggers Error 522

This differs from Error 521, where the server refuses connections entirely. With Error 522, the server attempts to respond but cannot keep up.


Why Error 522 Is a Serious Problem

Timeout errors damage both user experience and search visibility.

  • Visitors abandon slow pages
  • Crawl efficiency drops
  • Conversions fall
  • Infrastructure appears unreliable

Search engines prioritize stable websites. Frequent timeouts can weaken trust signals.


What Causes Error 522?

1. Server Overload

This is the most common trigger.

When CPU, RAM, or I/O capacity is exhausted, the server queues requests instead of answering them.

Typical overload sources:

  • Traffic spikes
  • Bot attacks
  • Heavy plugins
  • Poor caching
  • Large database queries

If resource usage is consistently high, infrastructure needs scaling.


2. Firewall Blocking CDN Requests

Security layers sometimes slow or block proxy traffic.

Even partial blocking can cause handshake delays.

Check for:

  • Rate limiting rules
  • IP blocking
  • Intrusion prevention systems
  • Hosting firewalls

Allowlisting official CDN IP ranges often resolves the issue immediately.


3. Slow Database Performance

Servers frequently wait on database responses.

If queries take too long, the CDN never receives a reply.

Warning signs:

  • High MySQL usage
  • Long query times
  • Locked tables

Optimization dramatically reduces timeout risk.


4. Network Routing Problems

Packets sometimes travel inefficient paths between networks.

This can introduce latency beyond timeout limits.

While less common, routing issues typically require hosting-level investigation.


5. Keep-Alive Disabled

Servers that disable Keep-Alive force new TCP connections repeatedly.

This increases latency and can trigger timeouts under load.

Enabling Keep-Alive improves connection efficiency.


How to Fix Error 522 (Step-by-Step)

Step 1 — Confirm the Server Is Responding

  1. Pause the CDN temporarily.
  2. Access your server directly via IP.
  3. Run a response test.

No response indicates a hosting-side problem.


Step 2 — Check Server Load

Review real-time metrics inside your hosting panel.

  • CPU usage
  • Memory consumption
  • Concurrent connections

If resources are maxed out, reduce load immediately.


Step 3 — Restart Core Services

Restarting clears stalled processes.

  • Apache / Nginx
  • PHP-FPM
  • Database server

This alone resolves many incidents.


Step 4 — Whitelist CDN IP Ranges

  1. Download the official IP list.
  2. Add ranges to your firewall allowlist.
  3. Reload firewall rules.

Test the site again immediately.


Step 5 — Optimize Database Queries

Slow queries are silent performance killers.

Actions to take:

  • Enable query caching
  • Remove unused plugins
  • Optimize tables
  • Limit heavy cron jobs

Step 6 — Enable Caching

Caching reduces server workload dramatically.

Consider:

  • page caching
  • object caching
  • edge caching

Less processing equals faster responses.


Step 7 — Upgrade Hosting If Needed

If timeouts repeat, the infrastructure is likely undersized.

Warning pattern:

  • Frequent slowdowns
  • Resource throttling
  • Traffic sensitivity

Scaling early prevents future outages.


Advanced Troubleshooting

Inspect Server Logs

Logs reveal where delays originate.

Look for:

  • Connection queue warnings
  • Memory errors
  • Timeout messages

Analyze Traffic Spikes

Sudden traffic can overwhelm unprepared servers.

Use analytics to identify patterns.

Review Security Rules

Overly strict protection sometimes throttles legitimate traffic.

Balance security with performance.


Quick Diagnostic Table

Symptom Likely Cause Recommended Fix
Intermittent timeouts Server overload Scale resources
Works without CDN Firewall delays Whitelist IP ranges
Slow dynamic pages Database bottleneck Optimize queries
Timeouts during traffic spikes Insufficient capacity Upgrade hosting

How to Prevent Error 522

Use Scalable Hosting

Infrastructure should handle growth without performance collapse.

Implement Strong Caching

Caching reduces response times and protects servers during spikes.

Monitor Server Health

Early alerts allow proactive fixes.

Optimize Applications Regularly

Remove heavy plugins and inefficient scripts.


When Should You Contact Hosting Support?

Escalate quickly if:

  • timeouts repeat frequently
  • resource usage appears normal
  • routing problems are suspected

Ask direct questions about network latency and server limits.

Commands to Fix Error 522 on Your Server

Error 522 means Cloudflare’s TCP connection to your origin timed out: packets are being silently dropped or the server is too overloaded to accept. Replace example.com and 203.0.113.10 with your values.

1. Confirm the origin IP in Cloudflare DNS is correct

A stale A record after a server move is a classic 522 cause. Compare the IP in the Cloudflare DNS tab with your server’s real address:

curl -4 -s https://ifconfig.me   # run on the server: its public IPv4
ip -br addr
dig +short example.com A          # proxied records return Cloudflare IPs - that's expected
dig +short example.com @1.1.1.1
nslookup example.com
# Check the origin IP set in the Cloudflare DNS tab answers at all:
ping -c 4 203.0.113.10
nc -vz -w 5 203.0.113.10 443

2. Test the connection to the origin

A hang (no "refused") points to a firewall DROP rule or a network issue.

# Replace with your domain and your origin server's real IP
curl -svo /dev/null https://example.com/ --resolve example.com:443:203.0.113.10
# Plain HTTP on port 80
curl -svo /dev/null http://example.com/ --resolve example.com:80:203.0.113.10

3. Allow Cloudflare through the firewall

DROP rules, rate limits and Fail2ban bans on Cloudflare IPs cause timeouts. Allow the ranges from Cloudflare’s official IP list:

# UFW: allow Cloudflare ranges on 80/443
for ip in $(curl -s https://www.cloudflare.com/ips-v4) $(curl -s https://www.cloudflare.com/ips-v6); do
  sudo ufw allow proto tcp from "$ip" to any port 80,443 comment 'Cloudflare'
done
sudo ufw reload

# iptables (IPv4):
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
  sudo iptables -I INPUT -p tcp -s "$ip" -m multiport --dports 80,443 -j ACCEPT
done

# CSF: add each range to /etc/csf/csf.allow, then
sudo csf -r
# Fail2ban: make sure no Cloudflare IP is banned
sudo fail2ban-client status
# Look for DROP rules and connection limits
sudo iptables -L INPUT -n --line-numbers | grep -E 'DROP|REJECT|connlimit'

4. Check server load and connection backlog

If the server is overloaded it may not accept new connections in time.

uptime
free -m
sudo ss -s
sudo ss -tn state syn-recv | wc -l

On busy Nginx servers, raise worker limits:

# nginx.conf
worker_processes auto;
events { worker_connections 4096; }

5. Keep-alive settings

Cloudflare reuses connections. Make sure keep-alive is on:

# Nginx (http {})
keepalive_timeout 75s;

# Apache
KeepAlive On
KeepAliveTimeout 5

Frequently Asked Questions

What is Cloudflare Error 522?

Cloudflare could not complete a TCP connection to your origin server in time.

What usually causes Error 522?

An overloaded server, a firewall blocking Cloudflare IP ranges or network routing problems.

How is 522 different from 521?

521 means the origin refused the connection; 522 means the connection attempt timed out.

Is Error 522 a CDN issue?

No. It usually indicates that the origin server is too slow to respond.

Can Error 522 affect SEO?

Yes. Repeated timeouts can reduce crawl efficiency and weaken reliability signals.

What is the fastest fix?

Check server load and restart services. Then verify firewall rules.

Will better hosting prevent it?

In many cases, yes. Scalable infrastructure reduces timeout risk.


Final Thoughts

Error 522 is usually a performance warning. Your server is reachable — but struggling.

Focus on speed, capacity, and efficient configuration. Stable infrastructure protects rankings, revenue, and user trust.


Related Cloudflare & CDN Errors

If you are troubleshooting a Cloudflare or CDN issue, you may also encounter related errors. Each code points to a different layer of the connection process:

Understanding how these errors differ helps you diagnose issues faster and identify whether the problem is related to networking, SSL, firewall configuration, or server performance.

Leave a Comment