In most cases, a HTTP 502 or 504 errors occurs because your origin server (e.g. your web host) is returning this code to us, and CloudFlare returns this code in turn to your visitors.
However, on some occasions this error is returned by CloudFlare before contacting your origin server, and in that case, the error page will look specifically like this:
Please note that the name “cloudflare-nginx” appears at the bottom of the error message. If you do not see this, then this error is *not* coming from CloudFlare, and instead is coming from your origin server.
If you do see “cloudflare-nginx” in the error page, please run a traceroute from your machine to your domain, and point your browser to “http://yourdomain.com/cdn-cgi/trace” (replace yourdomain.com with your actual site). Then open a support ticket and copy-paste both the traceroute result and the information shown in your browser.
As mentioned previously, most of the time these error codes are actually coming from your origin web server. It might look like the screenshot below, but depending on the web server you run and the amount of customisation you have done, it may look completely different as well.
In this case, and you should contact your hosting provider for further troubleshooting. Reviewing the access & error logs of your web server is a great place to start when these errors occurs as they should:
- confirm the response code is being returned by your web server (this is visible in your access logs)
- give some indication as to why (this is visible in the error logs, typically)