What should I do after seeing a 502 or 504 gateway error on my site?

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” 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” 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 or review your own logs if you manage your server yourself.

Note that 502s and 504s can be returned by any HTTP-aware device. If you have any load balancers or local proxies in place and do not see errors in the logs of the server that handles that page, check other infrastructure between your origin and Cloudflare also.

Still not finding what you need?

The Cloudflare team is here to help. 95% of questions can be answered using the search tool, but if you can’t find what you need, submit a support request.

Powered by Zendesk