Error 502 or 504
An HTTP 502
or 504
error indicates that Cloudflare is unable to establish contact with your origin web server.
There are two possible causes:
You may also see 504
status codes in logs or analytics caused by cache MISS responses from Early Hints.
To resolve 502/504
errors, it is essential to identify whether the issue originates from your origin web server or Cloudflare. In the following sections, you can find more details for troubleshooting and resolving errors from both sources.
Cloudflare returns a Cloudflare-branded HTTP 502
or 504
error when your origin web server responds with a standard HTTP 502 bad gateway
or 504 gateway timeout
error:

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
or504
error. - Investigate excessive server loads, crashes, or network failures.
- Identify applications or services that timed out or were blocked.
A 502
or a 504
error originating from Cloudflare appears as follows:

If the error does not mention cloudflare
, contact your hosting provider for assistance. Refer to 502/504 errors from your origin for more information.
This error can occur due to a compression issue at the origin, such as when the origin server serves gzip-encoded compressed content but fails to update the content-length
header, or if the origin is serving broken gzip compressed content. To diagnose this, you can try disabling compression at your origin to confirm if it resolves the error.
Additionally, in some cases, a particular data center may experience a sudden increase in traffic. To ensure minimal impact for customers, our automated processes will redirect traffic to another data center. These adjustments typically happen seamlessly and take just a few seconds. However, during this process, some clients may experience temporary latency or HTTP 502
errors. You can find more information about our automated traffic management tools in this blogpost ↗.
If you need further assistance from our Support team, provide the following details to Cloudflare Support to avoid delays in processing your inquiry:
- The time and timezone when the issue occurred.
- The URL that resulted in the HTTP
502
or504
response (for example,https://www.example.com/images/icons/image1.png
). - The output from browsing to
<YOUR_DOMAIN>/cdn-cgi/trace
.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark