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

avatar 2020年2月7日18:42:14How to Fix Cloudflare’s “Error 520: Web Server Is Returning an Unknown Error”已关闭评论

Try the suggestions in this Community Tip to help you fix “Error 520: Web server is returning an unknown error”.

Error 520 is essentially a catch-all response when something unexpected happens or when the origin server incorrectly interprets or does not tolerate a request due to a protocol violation or an empty response. A 520 error occurs when the connection started on the origin web server, but that the request was not completed. The most common reason why this would occur is that either a program, cron job, or resource is taking up more resources than it should causing the server not to be able to respond to all requests properly. When this happens, you’ll see “Error 520: Web server is returning an unknown error”.

Quick Fix Ideas

  1. Your web server or networking equipment, any http aware device like Firewall, Load Balancer, et al, reset the TCP connection after it was established. Sometimes when a web server crashes it will reset the connection. Check your web server error logs with your hosting provider for the time that the error occurred to see any error messages.
  2. Your web server returned an invalid response that exceeded our limits. Often this can happen if your web server is returning too many/too large headers. This is often caused by runaway scripts that return too many cookies, for example. The Code Igniter PHP framework has some known bugs around this, too.
  3. While you’re having a conversation with your hosting provider, make sure to white list Cloudflare IPs 383.
  4. While the 520 error can be triggered by unique and seemingly strange edge-case scenarios, they are generally caused by: Connection resets (following a successful TCP handshake), Headers exceed the Cloudflare header size limit (over 8kb), An empty response from origin, An invalid HTTP response, Missing response headers from an HTTP response, or the Presence of multiple Content-Length headers.
  5. Note that if Always Online is enabled, this error will trigger an Always Online page 141 to be served.
  6. If this error is still happening, contact Cloudflare Customer Support 176 and provide example URL(s) and Ray ID and output from a traceroute from any impacted user, copy the output of 120. Also include two HAR file(s) 65: one detailing your request with Cloudflare enabled on your website and the other with Cloudflare temporarily disabled - see How do I temporarily deactivate Cloudflare 99? These HAR files will be helpful in comparing server responses.