How to Fix Error 521 with WordPress and Cloudflare

0 0
Read Time:6 Minute, 55 Second

Are you looking for a way to fix ‘Error 521’ with WordPress and Cloudflare? 

If you’re seeing this error message, then so is everyone who tries to visit your website. This is bad news for the visitor experience and your conversion rates. It may even cost you your search engine rankings.

In this article, we will show you how to fix the 521 error with WordPress and Cloudflare.

Often this is because your server is offline.

But don’t worry, we have five troubleshooting steps that you can follow to fix this error quickly.

If you’re unsure what’s causing your 521 error, then we recommend starting with step 1 and working your way through the each step. If you prefer to jump straight to a particular step, then you can use the links below.

When you get a 521 error, there are steps you can take to fix the problem yourself. However some of them can be time-consuming and technical.

If you’re unsure how to contact support, then head over to your hosting provider’s website. You can then look for any Contact Us or Support pages. 

If you’re unable to get support from your hosting provider right away, then you can try the following steps.

When you get a 521 error, it’s always worth checking whether your server is online. 

If it’s still online, then you can try other troubleshooting steps.

You can use this IP address to ‘ping’ the physical server that hosts your WordPress website. If the server responds, you’ll know that it’s online. 

If it doesn’t respond, then your server is offline and this is what’s causing your 521 error. 

Once you’re logged in you can look for any settings labeled ‘IP address.’ 

On this screen, find the General Information section.

Bluehost will show your server’s IP address under ‘Shared IP address.’

If you’re struggling to find this IP address, it’s always worth checking your hosting provider’s website or online documentation. Many web hosts have detailed tutorials showing you how to find your IP address.

To do this test, simply paste your IP address into the ‘URL’ field. 

Then add ‘http://’ in front of your IP address. This turns this string of numbers into a web address. For example:

56.18.270.000

Becomes:

http://56.18.270.000

Next, click on the Check button. HTTP Header Checker will now try to talk to your server.

If your server is offline, then you’ll see a message such as ‘Failed to connect’ or ‘Host Not Found.’ 

This explains why you’re getting the 521 error. In this case, you’d need to contact your hosting provider to fix it.

If your server is online, HTTP Header Checker will show a ‘2XX’ status code. You may also see a ‘3XX’ status code if your server is online but is temporarily redirecting to a new location.

If your server is online, then an outage or server downtime isn’t causing your 521 error. In that case, you can continue following this guide to fix the error.

The solution is to whitelist all the IP addresses that Cloudflare uses. By whitelisting an IP address, you’re telling your server to allow all requests coming from that address.

Once you’re connected to your server, you’ll need to open your website’s root folder. To reach it, simply open the folder that shows your website’s address. 

Next, open the ‘public_html’ folder. 

You should now see your website’s .htaccess file.

Some FTP clients hide sensitive files by default. If you don’t see an .htaccess file, then you’ll need to enable the ‘show hidden files’ option in your FTP client. 

If you’re using FileZilla, just select Server from the toolbar. Then click on ‘Force showing hidden files.’

When you’re ready to edit this file, simply Control-click on the .htaccess file.

Then, select View/Edit. 

This will open .htaccess in your computer’s default text editing program. 

Inside this file, find the ‘​​# BEGIN’ line. You’ll need to add all the Cloudflare IP addresses above this line.

To start, type the following on a new line:

order deny,allow

To whitelist an IP address, you’ll need to type ‘allow from’ and then either copy/paste or type the IP address. This means that:

103.21.244.0/22

Becomes:

allow from 103.21.244.0/22

You’ll also need to add each IP address on a new line.

After adding all the Cloudflare IP addresses, save your changes. You can now close the .htaccess file.

Now you can go ahead and visit your site, to see whether this has fixed ‘Error 521.’ 

Did you switch to Full or Full (Strict) mode, right before getting the 521 error? This may have caused the problem. 

When Cloudflare is in Full or Full (Strict) mode, it needs access to port 443. However, some servers prevent Cloudflare from accessing this port, which will trigger the ‘Error 521′ error.

The solution is to enable port 443 on your server. 

This process will vary depending on your hosting provider and your server’s settings. With that in mind, we recommend contacting your hosting provider and asking them to enable port 443 for you. 

Even with port 443 enabled, you may still get the 521 error when using Cloudflare’s Full or Full (Strict) mode. 

If you don’t provide an Origin Certificate, you may get an ‘Error 521.’ 

The good news is that Cloudflare can walk you through the process of creating this certificate, step by step.

Next click on the Create Certificate button. 

Cloudflare will now ask for a private key and a Certificate Signing Request (CSR). 

Do you already have a private key and CSR? Then simply select the ‘Use my private key and CSR’ checkbox.

You can now type your CSR into the ‘Certificate Signing Request (CSR)’ box. 

If you don’t have a CSR and key, don’t panic! Cloudflare can create these two things for you. 

To get started, select ‘Generate private key and CSR with Cloudflare.’

You can now choose whether to create an RSA key or an ECC key. 

Most security experts agree that ECC and RSA are equally secure. However, ECC has a shorter key length. This means that ECC keys are faster. 

For this reason, we recommend you create an ECC key.

Once you’ve made your decision, open the ‘Private key type’ dropdown. You can then select either RSA or ECC.

Next, scroll to the Hostnames field. Here you can add all the hostnames that you want to protect. This may sound complicated, but Cloudflare does a lot of the work for you. 

These default values should be enough to protect most websites. However, if you need to add more hostnames then you can just type them into the ‘Hostnames’ field.

Next scroll to the ‘Certificate validity’ section.

Your certificate will be valid for 15 years by default. 

Need more time? Then just open the ‘Certificate validity’ dropdown and choose a new value. 

When you’re happy with all the information you’ve entered, click on the Create button.

Cloudflare will now create your certificate. 

Cloudflare will then show an Origin Certificate and Private Key. You’ll need to copy this information into separate files.

NOTE: You won’t be able to see the Private Key again after leaving this screen. With that in mind, make sure you store this key somewhere safe.

You can now upload your Origin Certificate to your web server. The steps may vary depending on your hosting provider and server.

Once you’ve installed the Origin Certificate on your server, the final step is updating your SSL/TLS encryption mode. 

In your Cloudflare dashboard, go to SSL/TLS.

Now find the ‘SSL/TLS encryption mode’ section. 

In this section select ‘Full (strict).’ 

Cloudflare is now using your Origin Certificate. You can now check your site to see whether this has fixed the ‘Error 521’

source

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Previous post Magnet Forensics has a 51 per cent upside, says Laurentian
Next post The Best Drag and Drop WordPress Page Builders 2022

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published.