Cloudflare Error 522: 3 Confirmed Methods to Fix It

The Error 522: Connection timed out is a common server-side problem on websites that use . In this post, we will find out what causes Error 522 and how to fix it.

Make sure you have access as a server administrator, since as a server error the only possible option is to contact the webmaster of the website. However, if you have access to the origin server, continue reading to learn three methods to resolve this issue.

Similarly, we will share how to fix other related issues in order to avoid other Cloudflare errors.

What causes the 522 error?

Error 522: Connection timed out is a status of the HTTP code. A CDN service, such as Cloudflare, speeds up the network connection between a browser user and a website’s origin server. However, sometimes the server fails to respond within a given time.

This problem also means that the (TCP) between the web server and Cloudflare has failed. The TCP exchange is essential to establish a connection when this CDN service receives a user request.

So why is the origin server not responding in time? Here are some of the most common reasons behind connection timeouts:

  • Server overloaded. When an origin server has too many requests, it cannot respond in time.
  • The firewall blocks requests from Cloudflare. Some web hosting providers have firewall features that could block Cloudflare’s IP addresses, which flags requests from the CDN.
  • Wrong IP address. The addresses in your (DNS) do not match Cloudflare’s.
  • KeepAlive disabled. Cloudflare enables KeepAlive messages by default. If these are disabled, the connection setup fails.

Any of these cases can result in a 522 error on your website. Most browsers will display the same image and message, indicating that the problem is with the web host.

Important! Please note that this error is not caused by any Cloudflare failure. Also, this problem can happen if you use a premium or free version. Here is a summary of the Cloudflare error 522:

Error codeError 522bug typeServer errorError VariationConnection timed out – Connection timed outCauses of the errorThe server has reached the maximum limit
The firewall has blocked a Cloudflare IP address
wrong IP address
KeepAlive off

3 Steps to Fix Error 522: Connection Timed Out

With each step to resolve Error 522: Connection timed out, we are also going to share how to check the specific cause behind your error.

Important! First, if the web page is down for everyone and make sure it works correctly before continuing with the steps.

See also  is recommended by Romuald Fons as the best Web Hosting provider

1. Check if the web server is working

A common cause behind the Cloudflare 522 error is that the web server cannot receive HTTP requests as it is overwhelmed. This problem usually happens with shared hosting servers. To fix this error, check if the origin web server is up and accepting HTTP requests.

There are different ways to verify your site’s origin web server, including using the PING command for Linux (Packet Internet Groper) or the Traceroute for Windows. In both Linux and Windows, the is used to check the connectivity status of your website’s server.

Another reason why your origin server might not work is the high load of requests to your website. Therefore, check the to avoid reaching the limits. Each hosting provider has its own way of accessing this information.

If you are a user, go to hPanel -> use of orders and take a look at:

  • CPU usage: refers to the consumption of the Central Processing Unit (CPU). Try to keep 80% to avoid poor performance.
  • limited memory: The amount of memory that the account processes.
  • processes: The total number of all processes in the account.
  • Bandwidth: The amount of data transmitted in a given amount of time.

Hitting the maximum threshold on any of these metrics will slow down the website and cause this error. To determine if you have reached the limit, check to see if the purple line playing Red line in the graphs.

Here are some ways to improve performance and optimize server capacity:

  • Fewer plugins. Some of the plugins create more requests than necessary to the corresponding database, generating a high load on the origin server. Remove unnecessary plugins to avoid using too many server resources.
  • Check the code. Poorly optimized code can cause high CPU usage. If you’re comfortable editing your site’s web code, consider revising it for faster performance.
  • Upgrade or change your hosting plan. When you are close to reaching the memory limit, upgrade your or change it to another type of .

Also, check if there are any . If so, just wait until the maintenance is over and the speed is back to normal.

pro tip

We recommend checking order usage regularly to prevent Cloudflare error 522 from happening.

2. Check Cloudflare DNS settings

Cloudflare will import all DNS records when integrating to a domain. One of the records is address record (A record)in charge of connecting the domain with the IP adress from the origin web server.

See also  Trademark / Copyright

Therefore, a mismatch in the IP address can cause the message Error 522: Connection timed out. The A records on the hosting server and Cloudflare have to match to avoid this issue. Open the DNS zone editor and check the A records to fix this issue.

If you are a user, go to the DNS Zones Editor in hPanel. In the DNS settings, note the IP adress in Contentsbeside Type A.

Next, head over to the Cloudflare settings menu and click the button . In it, she checks the IP adress next to Type A. Make sure the IP addresses are the same on both DNS servers.

If the A records are different, change them in Cloudflare’s DNS settings. Click the button add record and add the IP address of the hosting server in the box IPv4 address. Click the button Save to process the changes.

This action should fix the Error 522: Connection timed out issue. Please note that DNS updates can take up to 24 hours to be reflected. However, you can make the process faster.

Another DNS setting to check is the . We recommend setting the encryption mode to Complete to prevent this problem from recurring.

3. Observe Other Web Server Settings

Another way to fix this is to check the server settings of the website. In particular, take a look at these three:

Activate KeepAlive

Cloudflare uses header input Keep Alive to keep connections established with the web server. KeepAlive is an instruction that keeps the TCP connection open with HTTP requests.

Disabling the KeepAlive message header on the origin web server causes a 522 connection failure error. Therefore, always to reduce the use of the CPU and memory of the server. To use this method, make sure you have access to one of the following files:

  • . Hypertext access helps configure additional features for websites in the . users can find this file inside the File Manager.
  • nginx.conf. This is the main configuration file for , the open source web server software.

To demonstrate how to enable the KeepAlive header, add the following code to the file .htaccess:

Header set Connection keep-alive

Allow Cloudflare IPs

Another reason behind the HTTP 522 error is a firewall feature that blocks Cloudflare IP addresses. Make sure to check IP filtering at your hosting provider to allow requests from Cloudflare IPs.

has a IP manager to allow access or block specific web addresses. go to hPanel -> Other -> IP Manager to control IP routing for your site. Include Cloudflare IPs in the section Allow an IP address and click Add.

See also  How to change the font size in WordPress

If your control panel doesn’t have an IP manager, use the file .htaccess inside of the File Manager. Add the code allow from and insert the Cloudflare IP addresses between the lines:

#DO NOT REMOVE THIS LINE

The code will look like the image below.

These changes will allow the server to accept requests from Cloudflare and should fix the error message.

Disable Cloudflare

If none of the above methods work, please temporarily disable this CDN service. Each web hosting provider has their own way of doing it.

Fix other Cloudflare errors

There are other HTTP status messages that Cloudflare users may receive. For example, Error 520: The web server returns an unknown error. Common causes of this issue are an origin web server failure or an incompatible response header from Cloudflare.

Steps to fix Error 520 include:

  • Make sure Cloudflare’s DNS records are correct.
  • Deactivate your file .htaccess.
  • Check headers and cookies.

Another possible issue is Error 521: Web Server Down, which is commonly due to misconfigured Cloudflare encryption or an unreachable server. Here are some of the ways to fix error 521:

  • Make sure the origin server is up and running.
  • Test the connection to the server.
  • Check your encryption settings.

We advise you to contact Cloudflare support services if these issues persist on your website.

conclusion

Cloudflare Error 522 occurs when a server takes longer than the specified time to respond to requests. Some of the most common reasons behind this issue are insufficient memory or CPU, an IP address being blocked by the firewall, and a disabled KeepAlive header.

Let’s recap the three solutions to this problem:

  • Check your connection and your memory.
  • Review Cloudflare’s DNS settings.
  • Configure your server settings.

Let us know in the comments section below which method works best for you.

Betania is a copywriter with a passion for digital marketing and website creation. She writes tutorials and performs SEO analysis on ‘s Content team. In her free time, she enjoys dancing, singing or watching a good classic movie.

Loading Facebook Comments ...
Loading Disqus Comments ...