Cloudflare returns an Cloudflare-branded HTTP 502 or 504 error when your origin web server responds with a standard HTTP 502bad gateway or 504 gateway timeout error.
Resolution
Contact your hosting provider to troubleshoot these common causes at your origin web server:
Ensure the origin server responds to requests for the hostname and domain within the visitor’s URL that generated the 502 or 504 error.
Investigate excessive server loads, crashes, or network failures.
Identify applications or services that timed out or were blocked.