How to Fix Cloudflare Error 522 (Connection Timed Out)
What Error 522 means
When you load a Cloudflare-protected site, Cloudflare connects to the site's real server — the "origin" — fetches the page, and hands it to you. Error 522 — "Connection timed out" — means the first half worked: Cloudflare opened a TCP connection to the origin. But then nothing came back. Cloudflare waited its full timeout window, the origin stayed silent, and Cloudflare gave up and showed you the 522 page.
The classic trigger is slowness, not deadness. A server that refused the connection would produce a 521; one that answered with garbage would produce a 520. A 522 server is alive enough to accept the connection and then gets stuck — a script running too long, a database query waiting on a lock, a server so overloaded that your request sits in a queue until the deadline passes. A rarer but real cause is a firewall silently dropping Cloudflare's packets: from Cloudflare's side, that also looks like a server that never answers. Either way, the fault is between Cloudflare and the origin — never inside your browser.
Common causes
- Hung scripts or locked database queries: a PHP worker waiting on a locked database row, a WordPress plugin calling an API that never responds, or a cron job running in the foreground — the request starts and never finishes.
- Overloaded or exhausted server: CPU pinned at 100%, memory exhausted and swapping, or too few PHP-FPM workers for the request load — responses queue up and miss Cloudflare's deadline.
- Firewall dropping Cloudflare's connections: fail2ban, CSF, or a host rate limiter treats Cloudflare's edge servers as a flood and silently discards their packets, which surfaces as a timeout.
- Heavy batch jobs during peak hours: backups, imports, and batch exports that run while visitors are arriving steal the resources every request needs and create clusters of 522s on a schedule.
- Stalled third-party dependencies: a page that can't finish until an external API, payment gateway, or ad server replies — if that dependency hangs, every page it touches hangs with it and 522s appear across the whole site.
How to fix Error 522 — step by step
Steps 1 through 3 are for visitors. Steps 4 through 6 are for site owners.
- Visitor: wait a few minutes and hard-refresh. 522 errors are often transient — a one-off overload, a stuck database query, or a backup job hogging the server for a few minutes. Wait three to five minutes, then hard-refresh: Ctrl+Shift+R on Windows or Cmd+Shift+R on Mac. Many 522s clear on their own once the server works through its queue, so patience is genuinely the highest-yield first step.
- Visitor: check whether the site is down for everyone. Open the page in a private or incognito window, try it on your phone over mobile data, or ask a down-detector service like Down for Everyone or Just Me. If the site loads for anyone else, the stall is on your side of the path — restart your router, disable your VPN or proxy for a moment, and try again. If nobody can reach it, the origin server is too slow for Cloudflare's timeout and only the site owner can fix it.
- Visitor: disable your VPN, proxy, or ad-blocking extension and retry. VPNs and proxies add extra hops that can push an already-slow site past Cloudflare's response deadline, and some ad blockers and browser extensions hold requests long enough to trip the timeout. Turn off the VPN, switch extensions off, and reload. If the page appears, the site is marginal and your middlebox was the last straw — leave the VPN off for that site or try again on a different network.
- Site owner: find the slow or hung work on the origin. A 522 means Cloudflare's initial connection to the origin succeeded but no response arrived within the timeout — the classic cause is a script that runs too long. Check the origin's process list and slow-query log: PHP scripts stuck on a locked database row, WordPress cron jobs or plugin updates running in the foreground, or an API the page depends on that has itself stopped responding. Kill the hung process, fix or index the slow query, and disable plugins one by one until the response time returns to normal.
- Site owner: check server resources and request queueing. Look at CPU, memory, disk I/O, and the web server's connection queue at the time of the 522 reports — a server at 100 percent CPU or deep in swap cannot answer anything in time. Common triggers: a traffic spike the plan can't handle, backups or batch jobs running during peak hours, or a runaway process eating cores. Scale the plan, move heavy jobs off peak hours, and confirm PHP-FPM or your app server has enough workers so requests are not queueing behind stalled ones.
- Site owner: make sure the firewall is not dropping Cloudflare's connections. Firewalls, fail2ban, CSF, and host-level rate limiters sometimes treat Cloudflare's edge servers as a flood and silently drop their packets — from Cloudflare's side that looks exactly like a timeout, hence a 522. Allowlist Cloudflare's published IP ranges in your firewall and any security plugin, and raise the connection limits so the edge nodes are never throttled. Then verify by loading the site through Cloudflare again; if the 522 is gone, the block was the whole problem.
Did this fix it? Quick checklist
- A hard refresh after waiting three to five minutes loads the page (transient stall)
- A down-detector or another network confirms the site works for others
- The VPN and ad-blocking extensions are off and the page was retried cleanly
- Owner-side: hung scripts and slow queries are cleared, server resources look healthy, and Cloudflare's IPs are allowlisted
If the 522 appears in clusters at the same time every day, suspect a scheduled job — nightly backups, batch imports, and report exports that run during business hours are the usual suspects, and they produce 522s that vanish the moment the job ends. Owners should shift heavy work to quiet hours and watch the load graph; visitors seeing a daily 522 can simply wait it out and retry later. And if a 522 has been solid for an hour with no change, the origin is stuck in a way only the site's team can clear — check their status page or social accounts for an incident note rather than hammering refresh.
Frequently asked questions
What does Cloudflare Error 522 mean?
Error 522 — "Connection timed out" — means Cloudflare managed to open a connection to the website's origin server, but the server never sent a response back before Cloudflare's timeout expired. In plain English: the site's own server was too slow to answer, so Cloudflare gave up waiting. It is an origin-server performance problem, not a problem with your browser or with Cloudflare itself.
Is Error 522 my fault as a visitor?
No — 522 lives on the site's server. It means the server accepted Cloudflare's connection and then sat there without responding, which is a server-side slowness problem. The only visitor-side aggravators are a VPN or proxy adding latency on top of an already-slow site. Wait a few minutes, hard-refresh, try without your VPN, and if it persists, the site owner needs to speed up or unstick their server.
How is Error 522 different from 521, 520, and 524?
Each code describes a different point of failure between Cloudflare and the origin. 521 means the origin refused the connection outright. 522 means the origin accepted the connection but never answered in time. 520 means the origin answered, but its answer was empty or broken. 524 is the twin of 522: the origin answered and started a response, but the full response never arrived in time. For owners, 522 points at slowness or a firewall drop, while 524 points at a process that started and then stalled.
How long should I wait before a 522 is a real problem?
Give it three to five minutes and hard-refresh. Single 522s are often transient — a backup finishing, a stuck query being killed, a traffic spike subsiding. If the error repeats across every refresh, every device, and every network for more than about ten minutes, it is not transient: the origin is persistently too slow or stuck, and only the site owner can fix it. Visitors at that point should stop refreshing and check the site's status page or social channels.
I'm a site owner — what fixes a 522 fastest?
Start with the hung work: check for stuck PHP processes, locked database queries, or a plugin/API call blocking page generation, and kill or fix them — this resolves most 522s. Next, check server resources; a box at 100 percent CPU or in swap answers nothing in time, so scale up or move heavy jobs off peak hours. Finally, allowlist Cloudflare's IP ranges in your firewall and security tools, because dropped edge connections look exactly like timeouts. Retest through Cloudflare after each change.