Error 520 (Web Server is Returning an Unknown Error) on Cloudflare typically occurs when the origin server returns an unexpected response. Here’s how to troubleshoot and resolve this issue:
Steps to Solve Error 520:
-
Check Your Server Logs:
The first step is to review your origin server logs (Apache, NGINX, etc.). A 520 error often means the server is misbehaving or not responding correctly. Look for any server errors that coincide with the 520 error. -
Disable Conflicting Plugins/Modules:
If you are running a Content Management System (CMS) like WordPress or a web application, some plugins/modules may conflict with Cloudflare's proxy. Disable any caching, security, or performance-related plugins and try again. -
Verify Server Headers:
Cloudflare expects certain headers from your origin server. Missing or malformed headers (like content-length, cache-control) can trigger a 520 error. Check if your server is returning correct HTTP headers using debugging tools likecurl
or browser developer tools. -
Whitelist Cloudflare IPs:
Ensure that your server or firewall is not blocking Cloudflare's IP addresses. You may need to whitelist all Cloudflare IP ranges in your firewall or security plugins to allow proper communication between Cloudflare and your server. -
Restart Your Web Server:
Sometimes the issue may be temporary, caused by a stalled process on your origin server. Restarting your web server (Apache, NGINX, etc.) may resolve the issue. -
Check for Server Overload:
If your origin server is experiencing high traffic or resource usage, it may fail to respond to requests properly. Monitor your server’s CPU, memory, and bandwidth to ensure it's not overloaded. -
Review the .htaccess File:
If you are using an.htaccess
file for URL redirection or access control, improper configurations here may trigger a 520 error. Temporarily disable the.htaccess
file to check if the issue is related to these rules. -
Re-enable Cloudflare Proxy:
Try temporarily disabling Cloudflare proxy (set DNS mode to "DNS only" in the Cloudflare dashboard), then re-enable it to see if this resolves the issue. This can reset any temporary connection issues. -
Check SSL/TLS Settings:
If you're using SSL on your server, ensure the SSL/TLS settings on Cloudflare are set correctly. For most setups, using "Full" or "Full (Strict)" SSL mode will ensure proper communication between Cloudflare and your server.
By addressing these potential causes, you should be able to resolve Error 520 and restore proper access to your site.
For more detailed troubleshooting steps, you can refer to Cloudflare’s support page on Error 520.