How to fix Cloudflare error 522 Connection Timed Out

Last update: November 24th 2026
  • The failure occurs when the origin server does not respond in time to the TCP hello from the Cloudflare network.
  • The main causes are usually server resource overload, firewall blocks, or outdated DNS records.
  • The solution involves optimizing hosting capacity, enabling KeepAlive, and whitelisting Cloudflare IPs.

Blue screen of error on a data center console, illustrating a connection failure or timeout (Error 522).

I'm sure it's happened to you: you go to your website and, instead of your content, you're met with a blank screen and the dreaded Error 522: Connection timed out . Basically, this means that Cloudflare tried to contact the server hosting your website, but it didn't respond within the expected time. It's not that the website has disappeared; it's that communication between the proxy and the origin was interrupted before it even began.

The first thing you should know is that, even if the message appears while using Cloudflare, the problem is almost never with the CDN service, but with your own server or hosting . It's like calling someone and the line is busy or the phone is turned off; the operator does their job, but the recipient doesn't answer. To fix it, we'll have to adjust the server configuration and make sure everything is in order.

What exactly is happening on your server?

Close-up of modern server racks in a data center, representing the hosting infrastructure where the origin server resides.

Technically, error 522 occurs when the TCP handshake fails. Cloudflare sends a request and waits for about 15 seconds; if it doesn't receive a response, it issues the timeout warning. There are several reasons why this can happen, the most common being resource overload . If your CPU is maxed out or your RAM is exhausted, the server simply doesn't have the capacity to accept new connections.

Another very common reason is that the server is simply shut down or restarting. If the web server process (like Apache or Nginx) isn't listening on ports 80 or 443, the connection will always fail. It's also possible that there's a routing problem on the network, where data packets are lost on the way between the Cloudflare network and your hosting provider—something that happens less frequently but is a real headache.

  How to choose a reliable, fast and secure hosting for your website

Steps to fix Error 522

Network switches with green LED lights indicating active connectivity, ideal for illustrating communication between the Cloudflare proxy and the server.

If you're the site administrator, the first thing to check is that the server is up and running. A quick way to do this is to try accessing the website directly using its public IP address . If it works that way, you know the problem is with Cloudflare or the firewall. If it still doesn't work, the server is likely down or overloaded.

Hosting capacity optimization

When traffic spikes, the server can crash. It's crucial to monitor CPU and memory usage ; if they exceed 80%, requests will start piling up. To resolve this, you can remove unnecessary plugins that consume too many resources or optimize your website's code, especially slow database queries. If none of this works, it might be time to upgrade your plan and move from shared hosting to a VPS or a dedicated server.

Adjusting DNS records

Sometimes the problem is simpler: Cloudflare is trying to access a network that no longer exists. If you've migrated servers or your hosting provider has changed your IP address, the A record in your Cloudflare control panel will be outdated. You need to go to the DNS section of your Cloudflare account and verify that your IPv4 address exactly matches the one provided by your hosting provider. Keep in mind that these changes can take a few hours to propagate globally.

Firewall configuration and whitelist

It's very common for the server's firewall to see so many requests coming from Cloudflare IPs that it mistakes them for an attack and blocks them. To prevent this, you must explicitly allow Cloudflare's IP addresses in your firewall (either using iptables, nftables, or your hosting control panel). If you're using an .htaccess file, you can add the `allow from` directive followed by the official CDN IPs to allow traffic to pass through without problems.

  Windows Dedicated Servers: The Choice for Your Business

High-performance server unit illuminated in blue, representing CPU and RAM optimization to avoid overloads.

KeepAlive Activation

Cloudflare uses the Keep-Alive header to keep connections open and avoid having to create a new one for each request. If your server has this disabled, the connection will constantly close, increasing the likelihood of 522 errors. On Apache servers, you can force it by adding the code `Header set Connection keep-alive` inside an `ifModule` block in your `.htaccess` file. On Nginx, make sure the `keepalive_timeout` value is reasonable, such as 65 seconds.

Differences with other similar errors

Enterprise server rack with status lights and organized cabling, illustrating server monitoring and firewall configuration.

It's easy to confuse error code 522 with other codes. For example, Error 520 is a generic failure where the server responds, but in a malformed way. Error 521 is more definitive: the server actively rejected the connection (port closed). On the other hand, Error 524 occurs when the TCP connection is established successfully, but the server takes too long to send the HTTP response, usually due to a script that hangs.

To prevent these problems from recurring, the ideal solution is to implement a monitoring system like UptimeRobot that alerts you the second the website goes down. Keeping DNS records up to date and not letting server resources reach their limit are the best defenses. If, after trying everything, you're still experiencing the problem, a definitive test is to pause Cloudflare ; if the website still doesn't load, the fault lies entirely with your server and not the proxy configuration.

In short, resolving this issue requires a systematic analysis that begins with verifying server availability, continues with correctly aligning IPs in the DNS, and concludes by adjusting the firewall and connection headers. The key lies in ensuring that the path between the Cloudflare network and your hosting is unobstructed and that the hardware has sufficient power to respond to requests in real time.

FAQ

Why am I getting error 522 if my website works when accessed via IP address?
How can I tell if my server is overloaded and causing error 522?

You should check your hosting control panel and monitor CPU and RAM usage. If these metrics consistently exceed 80%, the server will not be able to process requests in a timely manner.

What is the A record and how does it influence this failure?

The A record links your domain name to the server's IP address. If this IP address is incorrect in the Cloudflare control panel, requests will be sent to a non-existent destination, causing a timeout.

What is the purpose of enabling KeepAlive on the server?

It allows the TCP connection to remain open for multiple requests, avoiding the overhead of creating a new connection each time. This improves performance and reduces the likelihood of connection errors.

Could error 522 be caused by a WordPress plugin?

Indirectly, yes, since a poorly optimized plugin can consume all of the server's memory or CPU. This causes the server to become unresponsive to Cloudflare, resulting in a timeout error.

What is the difference between error 522 and 524?

In 522, the connection fails to establish due to a TCP handshake failure. In 524, the connection is successful, but the server takes too long to generate the final response.

What should I do if I've tried everything and the error persists?

It's recommended to temporarily pause Cloudflare to see if the site loads directly. If it's still down, the problem is internal to the server; if it loads, the issue lies in the routing or firewall between the server and Cloudflare.

TecnoDigital

TecnoDigital

Passionate about technology and software development, I delve into the world of systems and computing with the aim of fostering innovation and solving complex challenges.