Hostingweb.info

6 Ways To Fix Cloudflare’s Error Code 521 in WordPress


You being here suggests that your website’s visitors are getting error code 521 when they enter the URL in the browser — i.e., your website is inaccessible to your customers.

Knowing that such a downtime can cost more than $300,000 for 91 percent of enterprises, let’s quickly figure out what error 521 means and how to troubleshoot it.

Here’s what we’ll cover:

What is error code 521?

Error code 521, or “Error 521: Web server is down,” is an error your visitors see if Cloudflare can’t access your website’s server. In other words, your visitors can reach the servers of your content delivery network (CDN), but the CDN can’t reach you.

What causes error code 521?

Error code 521 is typically associated with web technology, specifically indicating that the web server is down when using Cloudflare as a reverse proxy or CDN (Content Delivery Network).

This error means that while Cloudflare’s servers are able to connect to the internet and reach your website’s domain, they are unable to establish a connection to your website’s server; thus, Cloudflare cannot serve the webpage to the visitor.

Here are common reasons for this error:

  • Server offline: The most straightforward cause is that your web server is not running or is unreachable due to network issues.
  • Firewall blocks Cloudflare: Your server’s firewall may mistakenly identify Cloudflare’s requests as malicious and block them. This can happen if Cloudflare’s IP ranges are not allowed through the firewall.
  • Incorrect DNS Settings: If your DNS settings are misconfigured or have not fully propagated, Cloudflare might not be able to find your server.
  • Server overload or resource issues: If your server is experiencing high traffic or resource constraints, it might not be able to respond to Cloudflare’s requests in time.
  • SSL/TLS handshake failure: If there’s an issue with your SSL/TLS certificate or configuration, Cloudflare might not be able to establish a secure connection to your server.

How to fix error code 521

Now that we know what error 521 is let’s see how to troubleshoot it.

1. Verify that your website is online

When you set up Cloudflare as a reverse proxy for your website’s server, it acts as a bridge between your customers and your website. Your website visitors pass through this bridge to find your website on the other end.

If your visitors encounter error 521, the first thing you need to do is check if the bridge’s destination is still online.

You can use the cURL command to interact directly with your website’s server and request a response.

Open the command prompt or terminal (if using macOS or Linux) and enter the following code:

curl –silent –output /dev/null –write-out “%{http_code}” https://yourwebsite.com

Note: Replace “https://yourwebsite.com” with your website’s URL.

You’ll get an output in the form of an HTTP status code. If it’s 200, your website server is online.

For instance, here’s the output of this code if we use cURL to interact with our website.

If you don’t want to work with the command prompt or terminal, try out KeyCDN’s HTTP Header Checker.

However, getting a 5xx status code means the server failed to respond to your request — and you have a server error.

Note: If you get HTTP code 301, don’t worry. It means that WordPress has set up a 301 redirect for non-WWW to WWW URL, or vice versa. That typically happens if your website’s default address is “https://www.nexcess.net,” and you enter “https://nexcess.net.” You may enter the correct address to get the actual response code.

In case of a server issue, bring it up with the hosting provider’s support team to see if they’re doing any maintenance on the server. You can also check your hosting provider’s status page to see if the servers are offline.

Alternatively, if your hosting provider doesn’t offer immediate support, you may check out the error logs via cPanel to troubleshoot the server issues.

If your hosting provider’s servers suffer from frequent downtimes, consider Nexcess. We reliably offer almost 100 percent uptime with all our hosting plans. Besides that, our expert support team is available 24/7/365 to help you with any technical issues.

2. Remove blockers between Cloudflare and your website

If your website is online, the error 521 might be due to a misconfiguration preventing Cloudflare from accessing your website’s files.

The issue can be in your .htaccess file, IP Blocker rules, or security plugin. Let’s see how to fix each one.

Whitelist Cloudflare IP addresses in your .htaccess file

Cloudflare uses a set of IP addresses to direct incoming traffic to your web server. Ensure all those IP addresses are whitelisted or allowed on your web server.

Here’s how to whitelist IP addresses in the server configuration:

1. Open the .htaccess file via an FTP client or using the file manager in cPanel.

2. Add the following code:

order deny, allow
deny from all

3. Add allow from [Cloudflare IP addresses]. Replace [Cloudflare IP addresses] with one of the actual IP addresses on each line, as shown in the image below.

4. Save your .htaccess file.

Check IP Blocker settings

If you’re using a cPanel-based host, IP Blocker can help you block your website from a specific IP address or a range of IP addresses.

Review the IP Blocker settings to ensure one of the admins hasn’t added Cloudflare IP ranges to it by mistake.

Disable your security plugin

There’s a chance your security or firewall plugin might be blocking Cloudflare requests. To rule that possibility out, disable the plugin and see if it resolves error 521. If it does, contact the plugin developers or replace your security plugin.

3. Review Cloudflare DNS settings

Log in to your Cloudflare account and navigate to [yourwebsite.com] > DNS > Records.

Once there, ensure that content for all A records matches the origin web server’s IP address and that the content for CNAME records contains your website’s domain name.

If one of the records is incorrect, you may modify the record by clicking Edit.

4. Install a valid SSL on the origin web server

If you’ve configured the SSL/TLS settings on Cloudflare as Full (strict), Cloudflare performs a certificate validation between itself and your server.

And if your website’s SSL certificate comes across as expired or self-signed or doesn’t match the domain, Cloudflare will cut off the connection. In that case, your visitors will see error 521 in their web browser.

You may need to install a Cloudflare Origin Certificate Authority (CA) certificate on your server to fix this issue. You can get a Cloudflare Origin CA certificate by navigating to [yourwebsite.com] > SSL/TLS > Origin server and clicking Create certificate.

Afterward, you can add the Cloudflare origin certificate to your web server by following your hosting provider’s directions.

However, if you manage sensitive data or need to comply with PCI-DSS requirements, you may be better off with a premium SSL certificate.

5. Deactivate mod_reqtimeout and mod_antiloris

You might have enabled mod_reqtimeout and mod_antiloris modules on your Apache HTTP server to prevent denial-of-service (DoS) and distributed denial-of-service (DDoS) attacks. The modules shield your web server from these attacks by limiting the number of times an IP server can connect with your server.

While mod_reqtimeout and mod_antiloris serve as a protective shield for your hosting server, they might have incompatibility issues with Cloudflare.

For instance, Cloudflare relies on a limited number of IP addresses to direct traffic to your server, but the modules might block those addresses due to consecutive connection attempts.

6. Contact customer support

If none of the solutions above work for you, it’s time to get outside help.

Get Cloudflare’s support via ticket, chat, or phone by navigating to Support > Contact Cloudflare if your website functions fine without Cloudflare’s CDN.

If the website’s hosting server is down, contact your web hosting provider’s support team. With Nexcess, you get 24/7/365 support from expert technicians who handle the troubleshooting from start to finish and let you focus on other business tasks.

Final thoughts: 6 ways to fix Cloudflare’s error code 521 in WordPress

If you own an ecommerce business or manage an enterprise, you don’t want to keep seeing error code 521 for long. Every second your website stays inaccessible, you leave more money on the table.

With the tips above, you can try to fix the error as soon as possible. However, prevention is better than cure.

At Nexcess, our experts handle the server configuration for you, so you rarely have to worry about an error 521. Not to mention, our enterprise hosting plans come with 24/7/365 support from elite technicians, always on standby if anything breaks loose.

Besides that, you can also try our free built-in Nexcess Edge CDN, which is powered by Cloudflare, to bypass error code 521 since Nexcess experts handle everything, as opposed to Cloudflare itself, where you have to configure the CDN manually.

Check out our hosting plans to get started today.

FAQs

1. How common is an error 521?

Error 521 is a relatively common error for websites using Cloudflare, especially if there are misconfigurations in server settings, firewall rules, or during high traffic periods that the server cannot handle.

2. How can I prevent Error 521 from happening?

To prevent Error 521, you can:

  • Ensure server uptime: Regularly check your server for any downtime and ensure it’s correctly configured and running.
  • Configure Firewall settings: Make sure your server’s firewall has Cloudflare’s IP ranges whitelisted.
  • Check DNS settings: Ensure your DNS settings are correct and have fully propagated.
  • Monitor server resources: Keep an eye on your server’s resource usage to prevent overloads.
  • Review SSL/TLS settings: Verify that your SSL/TLS settings and certificates are properly configured and up to date.

3. Do I need to access my server to fix Error 521?

Yes, resolving Error 521 typically requires server access because you’ll need to verify its operational status, firewall rules, DNS configurations, and SSL/TLS settings. If you manage your server directly, you can make these checks yourself. However, if you’re using a hosting provider, you may need to contact them for assistance, especially if you need help with server configuration or if the server is down.

4. Can Error 521 affect my website’s SEO or user experience?

Yes, frequent occurrences of Error 521 can negatively impact your website’s user experience by making it inaccessible to visitors, which in turn can harm your site’s SEO rankings. Search engines prioritize the reliability and speed of websites when ranking them. Regularly encountering errors like 521 can decrease your website’s perceived reliability.



Source link

Leave a Comment

Your email address will not be published. Required fields are marked *