How to Fix Cloudflare’s “Error 520" ? GreggHosting

The affects of Web Hosts on Your Business Website

Here're ways your choice of web hosting service provider impacts the performance of your business:


check

Website loading speed

check

Uptime and availability

check

Customer support

check

Security

check

Server location

How to Fix Cloudflare’s “Error 520: Web Server Is Returning an Unknown Error”?

How to Fix Cloudflare’s “Error 520: Web Server Is Returning an Unknown Error”?

Error 520

Fix Cloudflare’s “Error 520: Web Server Is Returning an Unknown Error”

When visitors to your site encounter error 520, it implies Cloudflare is sending the message because your server provided an empty, unknown, or unexpected response.

The 520 error can be approached by troubleshooting first to determine the reason, and then by following these steps to resolve the issue.

Let’s get started:

Contents Table of Contents

Troubleshooting Error 520
Error 520: Common Causes and Solutions
Re-enabling Cloudflare
What Should You Do If Everything Else Fails?
Error 520 Troubleshooting
Because the 520 error is caused by a problem on your server, you can troubleshoot the problem by checking your error log.

Error code 520
An example of a website error 520.
Cloudflare should be turned off.
Cloudflare must be disabled before troubleshooting can begin. This helps isolate the problem by ensuring that the problem can be duplicated without the use of Cloudflare.

1st step
To begin, sign in to Cloudflare. Then, on the list, look for your site and click on it.

Cloudflare’s control panel
Select the site you want to visit from the drop-down menu.
2nd Step
Then, under the Proxy status portion of the table, click on the orange cloud beneath the DNS tab. The cloud will have gone gray, indicating that Cloudflare has been disabled.

DNS (Domain Name System)
To turn off Cloudflare, click the orange cloud.
Cloudflare is currently paused.
After logging in, you can also choose to pause Cloudflare.

Step 1: From the list, select your connected site.

Cloudflare’s control panel
After logging in, select your site from the list.
2nd Step
Then, in the sidebar, scroll down until you see the Advanced Actions area. To stop Cloudflare from running on your site, click the Stop Cloudflare on Site link.

The Cloudflare dashboard page’s bottom
To pause Cloudflare, click the link.
3rd step
On the website, you’ll see a pop-up asking you to confirm that you wish to pause Cloudflare. Don’t hesitate to click the Confirm button.

Cloudflare’s pause confirmation pop-up
To pause Cloudflare, click Confirm.
Switch to the development mode
You can keep Cloudflare running but put it in development mode if you don’t want to pause or disable it. This will allow you to troubleshoot problem 520.

Step 1: After logging into Cloudflare, go to the top of the website and pick the Caching option.

The Caching page of Cloudflare
Go to the Caching section of the menu.
Step2
After that, scroll down to the Development Mode area and flip the Off switch. “On” should now appear.

The page for caching
By clicking the toggle button, you can enable development mode.
Examining the Error Logs on Your Server
You can troubleshoot error 520 by inspecting your server’s error logs now that you’ve deactivated, paused, or put Cloudflare into development mode.

If you’re unsure where to find your error logs, contact your host.

You can utilize the procedures below if your Hosting provider uses cPanel.

1st step
Go to the Metrics area of the dashboard after logging into cPanel. Then select Errors from the drop-down menu.

The cPanel control panel
Under Metrics, click the Errors button.
2nd Step
The error log page shows errors in reverse chronological order, as well as the most recent 300 messages. If you or your host changed the settings, the error log may show more errors.

The cPanel error log
To troubleshoot problem 520, look at the cPanel error log.
Checking for Error 520 in Your Logs Making use of MyKinsta
If you host your WordPress site with Kinsta, you may examine your error log by following the steps below.

1st step
Log into MyKinsta and select Sites from the left-hand menu. Then, from the list on the page, choose the site you wish to troubleshoot.

The dashboard of MyKinsta
In the MyKinsta menu, select Sites.
2nd Step
Select the Logs tab. The error log is displayed by default. If you don’t see anything displayed, it’s because there haven’t been any errors on your site.

The Logs tab is where you’ll see your logs.
The Logs tab displays any issues that have occurred.
How to Read and Understand the Error Log
An error log message has a structure to it. You can read the error messages that appear if you understand it.

[Friday, October 11th, 17:00:30 UTC] [error] [client 123.4.56] [client 123.4.56] [client 123.4. .7] description of the error: /path/to/file/with/error
The message’s date and time are listed first, followed by the LogLevel directive, which indicates the message’s severity level.

The client’s IP address comes next. This is the person that brought the problem to light.

Finally, the real notification appears, which may include a link to the damaged file.

The following are the LogLevel severity levels that may appear in your error log messages:

Emerg – This indicates that the problem is urgent and that the server is unavailable.
If you see this level, you should take quick action.
Crit — This denotes a life-threatening situation.
Error – This indicates that there has been a problem.
Warning — A message with this level is a warning about a problem that requires your attention but isn’t life-threatening.
Notice – This indicates that your server is normal, but there are important facts regarding its condition that are available.
This level provides access to general information.
When debugging is enabled, these messages include information.
To troubleshoot Error 520, use a cURL command.
You can also troubleshoot problem 520 by testing against the origin server with a cURL command.

curl -vso /dev/null —user-agent “Mozilla 5.0” -H “Host: your-site.com” curl -vso /dev/null —user-agent “Mozilla 5.0” -H “Host: your-site.com” http://123.45.6.789/wp-login.php
Make sure “you-site.com” is replaced with your actual domain. You’ll also need to replace “123.45.6.789” with the IP address of your site. If your login page has changed, you need also replace the “wp-login.php” section.

The following is an example of a successful response header:

* Trying 123.45.6.789… * Hostname not found in DNS cache Connected to port 80 (#0) at 123.45.6.789 (123.45.6.789) > HTTP/1.1 GET /login Mozilla 5.0 > User-Agent */* */* */* */* */* */* * > your-site.com as a host
HTTP/1.1 200 OK HTTP/1.1 200 OK HTTP/1.1 200 OK HTTP/1.1 200 OK HTTP
Date: Day, DD, Month Year Content-Type: text/html Timezone: Hour:Minute:Second
[Data: 12345 bytes]
* The connection #0 to the host 123.45.6.789 is still active.
If you see something similar to this, it signifies everything is fine and you were able to reach the site without receiving an error 520 response.

If you receive a response header that looks like the one below, it shows the 520 error happened when Cloudflare was active:

* Trying 123.45.6.789… * Hostname not found in DNS cache Connected to port 80 (#0) at 123.45.6.789 (123.45.6.789) > User-Agent: Mozilla 5.0 > GET /login HTTP/1.1 Accept: */* > Host: your-site.com > Accept: */* Accept: */* Accept: */* Accept: */* Accept: *
* Server’s response is empty * The connection #0 to the host 123.45.6.789 is still active.
How do I make a HAR file?
An HTTP archive file is known as a HAR. It keeps track of requests that go to the origin server as well as requests that travel through Cloudflare.

Because it compares response headers from the origin server and Cloudflare when it’s used as a proxy, it can aid debugging.

It’s also used to check if the headers are too large, which could be the cause of error 520.

The methods below will show you how to produce a HAR file using your browser:

Chrome
1st step
Right-click on the page in your browser. Then choose Inspect.

In Chrome, the page has been right-clicked.
In Chrome, right-click and select Inspect.
2nd Step
After the panel has opened, go to the Network tab and look for a red circle button in the upper left-hand side of the screen. Click it if it’s gray.

Chrome’s developer console
On the Network tab, make sure the record button is red.
3rd step
Click the clear button after checking the Preserve log option next to the record button.

Chrome’s developer console
After selecting the option to keep the log, click to clear prior messages.
4th step
Reload the page that’s causing the 520 problem. Then right-click anywhere in the Chrome developer tool’s messages section.

Save the file on your computer by selecting Save as HAR with Content.

A message has been right-clicked in Chrome’s developer tool.
The HAR file should be saved to your PC.
Firefox
1st step
Right-click anywhere on the page in Firefox. Then choose Inspect Element from the drop-down menu.

In Firefox, a page has been right-clicked.
After right-clicking on the page, select Inspect Element.
Step 2 Select the Network tab and navigate to the website where the 520 error appears. Select the Save All as HAR option by right-clicking on messages in the panel.

Save the file to your hard drive.

Firefox’s development mode Tab Network
Choose to save the HAR file by right-clicking.
Step 1: The Edge
Right-click the page in the Edge browser. Select Inspect from the drop-down menu.

Edge is a web browser.
After right-clicking in the browser, select Inspect.
2nd Step
Make sure the circular record button on the Network tab is red. Click it if it isn’t. To clear the current messages, check the Preserve log option, then the icon.

Do you want to discover how we grew our traffic by over 1000%?
Join the 20,000+ people who receive our weekly email with WordPress insider secrets!

Now is the time to subscribe.
The developer tool’s Network tab
To keep the log and delete previous messages, click.
3rd step
Go to the page where you’re getting the 520 problem. Then, in the developer tool panel, right-click on the messages and choose Save all as HAR with content.

Save the file to your hard drive.

Step 1 of Safari
For Windows, open Safari and right-click on the page, or for Mac, hit CMD and click. Choose Inspect Element from the drop-down menu.

Safari is a web browser.
After right-clicking on the page, select Inspect Element.
2nd Step
Select the Network option from the drop-down menu. Go to the page with the error 520 issue, then check the Preserve Log option.

The developer toolbar in Safari
On the Network tab, select the option to save the log.
3rd step
Save the HAR file to your PC by clicking the Export button.

Safari’s developer mode
The HAR file should be exported.
Resolving the Common Reasons for Error 520
Now that you have your error log, look through it to see whether any of the issues listed below are present. Then, to fix the problem, follow the instructions below.

PHP Application on the Origin Server Failed
One of the most typical reasons of error 520 is a server crash caused by one of the PHP applications. The error can be fixed by restarting PHP.

Step 1: For Apache servers, use SSH to run the command below:

restart apache2ctl
You can restart PHP on Nginx servers with the following command:

restart nginx service
In MyKinsta, restart PHP.
You can restart PHP in a few clicks if your site is hosted with Kinsta.

1st step
Log into MyKinsta and select Sites from the left-hand menu. Then, from the list, select your website.

The dashboard of MyKinsta
At MyKinsta, choose your site from the drop-down menu.
2nd Step
Click the Restart PHP button on the Tools tab.

To restart PHP and fix issue 520, go to the Tools tab in the MyKinsta dashboard.
In the MyKinsta control panel, you can restart PHP.
IP Addresses from Cloudflare aren’t whitelisted.
Another cause of the 520 error is if Cloudflare’s IP addresses are not whitelisted. You can whitelist them, however the procedure varies depending on the hosting provider.

Are you tired of having problems with your WordPress site? With Kinsta, you’ll get the best and fastest hosting support! Take a look at our plans.

Contact your host if you’re not sure how to whitelist IPs, especially if you can’t locate any settings for it.

Cloudflare’s IP addresses are whitelisted by default at Kinsta, so you don’t have to worry about this being the cause of the problem. It will also have no effect on the other causes of the mistake.

Idle timeouts on TCP are less than 300 seconds.
Error 520 could potentially be caused by the Transmission Control Protocol (TCP).

TCP (Transmission Control Protocol) is a standard protocol for establishing and maintaining network connections. If the TCP is set to timeout in less than 300 seconds, the 520 error may appear.

A CLI command can be used to alter the TCP service timeout:

set up the service 500 Headers Service-HTTP-1 -svrTimeout More than 8 KB
This problem is usually caused by a huge number of cookies or a large number of cookies. If this is the issue, the HAR file you downloaded during the debugging step will reveal you.

The maximum size of headers allowed by Cloudflare is 8 KB.

Reduce the number of cookies required by your plugin or the amount of data stored in its cookies if you wrote it. Alternatively, if you’re using a number of plugins that all require cookies, you can disable some of them (you should always use quality plugins).

Your Server’s Response Is Empty
When your site doesn’t have an HTTP status code or response body, you’ll run across this issue. To fix it, make sure your DNS settings for your site’s domain are accurate.

The ways to check your DNS settings vary depending on your DNS host. Check with your hosting provider if DNS is included in your hosting package.

It’s worth noting that if you changed your DNS settings, your site could take up to 72 hours to spread. This implies your website could be down for up to three days.

You must delete your site’s cache after altering your DNS settings. If you have a caching plugin installed on your WordPress site and aren’t sure how to delete the cache from the plugin’s settings, consult the instructions.

Your hosting provider can also help you erase the cache on your site. If you need to know how to do this for your site, be sure to ask them.

If your site is hosted by Kinsta, go to the Sites menu and select your site from the list.

Then, under the Tools page, select the Clear cache option.

In MyKinsta, go to the Tools tab.
MyKinsta can be used to clear the cache of your website.
If you’ve adjusted your DNS settings, your site is back online, and you’ve cleared the cache, but you’re still getting error 520, restart your server.

If you can’t find the option in your settings, please contact Kinsta’s support staff for assistance.

Response Headers Are Missing
Mozilla claims that

“A response header is an HTTP header that can be used in an HTTP response but has nothing to do with the message’s content. Response headers such as Age, Location, and Server are used to provide further information about the response.”

A variety of factors can result in missing response headers.

With this scenario, your best chance is to utilize a debugging tool like Fiddler to debug it and figure out exactly what’s wrong so you can repair it.

HTTP Error Responses aren’t being returned correctly by the server
The 520 problem could have been caused by your server sending an incorrect error response. This indicates that the message did not match the usual set of HTTP response codes.

It’s caused by your server, but it could also be something else on your server, such as PHP apps or WordPress plugins.

If you can’t figure out where the incorrect error code came from and how to rectify it, contact support for assistance.

Re-enabling Cloudflare
Check to see if the mistake occurs again. If this is the case, disable Cloudflare and continue troubleshooting.

Restart Cloudflare if the 520 error has been addressed.

1st step
To do so, log into Cloudflare and, if Cloudflare was disabled by setting the cloud gray in your account, begin by selecting your site from the list.

Cloudflare’s control panel
Choose the site where you wish Cloudflare to be enabled.
2nd Step
To re-enable Cloudflare, go to the DNS tab and click the gray cloud.

On the Cloudflare website, go to the DNS tab.
To use Cloudflare, click the gray cloud.
Step 1: Restart Cloudflare after it has been paused.
If Cloudflare was previously halted, you can reactivate it by login into Cloudflare and selecting your listed site from the dashboard.

Cloudflare’s control panel
Choose the site where Cloudflare needs to be restored.
2nd Step
Then, in the sidebar on the right-hand side of the website, go to the Overview tab and scroll down to the bottom of the page until you reach the Advanced Actions sections.

To enable Cloudflare on your site, click the Enable Cloudflare on Site link.

Cloudflare’s control panel
To re-enable Cloudflare, click the link.
Disabling Development Mode
1st step
If you’ve enabled Cloudflare’s development mode earlier, you can disable it by logging in. Then, on the page’s list of sites, click yours.

Cloudflare’s control panel
Choose a location.
2nd Step
Go to the Caching tab after that.

Cloudflare’s site has a Caching tab.
Toggle to the Caching tab.
3rd step
Scroll down to the Development Mode area and turn on the toggle button that says “On.”

The Caching Section
Disable development mode by clicking the toggle.
What to Do If All Else Fails
Contact Cloudflare support if you’re still having problems.

Give them the following information:

When the error occurred, the full URL(s) of the requested resource were returned.
The Ray ID of Cloudflare from the website where the error 520 message appeared.
Replace “your-site.com” with your actual domain name in the output from http://your-site.com/cdn-cgi/trace.
There are two HAR files: one from when Cloudflare was activated and another from when Cloudflare was disabled.
Is #Cloudflare throwing an Error 520 at you? Here’s how to diagnose it and resolve the problem! CLICK HERE TO TWEET
Summary
Because it’s a Cloudflare issue, the 520 error can be perplexing. However, it has to do with a server problem that prevents Cloudflare from connecting.

The solutions to the most prevalent causes of error 520 are listed above. If you’re still having problems after attempting these steps, you should contact Cloudflare or your hosting provider for assistance.

How to Set Up Cloudflare APO for WordPress is a recommended read.

Save time, money, and improve site performance by using:

Expert WordPress hosting assistance is available 24 hours a day, 7 days a week.
Integration with Cloudflare Enterprise.
With 29 data centers across the world, we can reach a global audience.
With our built-in Application Performance Monitoring, you can improve your performance.
All of this and more is included in a single plan that includes no long-term obligations, aided migrations, and a 30-day money-back guarantee. Check out our plans or speak with a sales representative to find the ideal plan for you.