How to Fix Error 520: Web Server Is Returning an Unknown Error

Cloudflare 520 error is a common error that triggers when the origin server returns an empty or unexpected response. This happens mainly when the server is unable to send a timely response due to a resource-intensive process.

As a part of our Server Management Services, we have helped online service providers to fix several similar Cloudflare errors.

Today, let’s discuss some tips to fix the error “Web server is returning an unknown error”.

What causes Cloudflare 520 error?

Cloudflare error 520 triggers when the origin server returns an empty, unknown, or unexpected response to Cloudflare. When a program, cron job, or resource is taking up more resources than it should, the server may not be able to respond to all requests properly. As a result, it triggers “Error 520: Web server is returning an unknown error”.

The possible reasons for this error include:

  • Origin web server application crashes: One of the major reasons for this error is the webserver application crash at the origin server. Execution of a resource-intensive script is the most probable reason that leads webserver application crash. As a result, the server will not be able to respond to the requests in a timely manner.
  • Cloudflare IPs not allowed at the origin: Origin server’s firewall can cause a hindrance while connecting through the IP address that is not whitelisted. Hence, if Cloudflare’s IP address is not whitelisted, it can, in turn, lead to the 529 error. Whitelisting it can fix the issue.
  • The origin web server TCP idle timeouts shorter than 300 seconds: TCP protocol establishes and maintains a network connection. If its timeout value is too low, it can trigger the unknown error.
  • Headers that exceed Cloudflare’s header size limit (8kb): Excessive use of cookies or the use of cookies that are large will increase the size of the headers. As Cloudflare has a limit of 8kb for the header size limit, it won’t be able to process the header.
  • Empty response from the origin web server that lacks an HTTP status code or response body: This generally happens when the DNS of the domain is pointing to a wrong server.

How to fix the Cloudflare 520 error?

Lets now look at some tips to fix this error.

Disable Cloudflare:

The first step in fixing the 520 error is to isolate the Cloudflare factor from it. There are several methods to perform this. We could either disable it from the Cloudflare Home page. We could also try turning off the Cloudflare DNS cloud to grey or pause the Cloudflare option.

Once it is turned off we could then search for the error logs to find further details of the error for the crash.

Restart the webserver

The major reason for the 520 error is the failure of the web server application. It primarily happens due to excessive resource usage in the server. We already have several blogs that discuss handling excessive resource usages.

Remove plugins

Larger header sizes can be related to excessive use of plugins that requires too many cookies. Some of them also store too much data in cookies. This makes the headers heavy and Cloudflare may not be able to handle them.

The fix here would be to try disabling those plugins one by one. If there are quite a lot of plugins that need cookies, it is also a preferred to remove some of them.

Ensure DNS is set properly in Cloudflare

An empty response from the origin web server generally happens due to an improper configuration of DNS entry at Cloudflare end. Thus it is not a bad idea to cross-check the existing DNS records added to the domain. Ensure that the A record points to the correct IP address.

Conclusion

In short, the 520 error in Cloudflare happens when the origin server returns an empty, unknown, or unexpected response to Cloudflare.

Rate this post
error: Content is protected !!