# Cloudflare 504 Gateway Timeout

> A Cloudflare 504 comes from your origin, from Cloudflare, or from harmless Early Hints cache misses. Tell them apart and know when it is really a 524.

Canonical: https://scaplet.com/errors/cdn/cloudflare-504

Guide Error · CDN and hosting

A Cloudflare 504 comes from your origin, from Cloudflare, or from harmless Early Hints cache misses. Tell them apart and know when it is really a 524.

5 min

read

8

sources

Oct 21, 2026

updated

Scaplet Editorial Team

author

In one line

A Cloudflare 504 Gateway Timeout comes from your origin web server (the most common source) or from Cloudflare itself. A Cloudflare-branded 504 means your origin returned that status; a blank, unbranded one came from Cloudflare. Some 504s in logs are harmless Early Hints or Workers cache misses. If Cloudflare connected but got no response in time, you would see 524 instead.

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Fcloudflare-504%20(%22Cloudflare%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Fcloudflare-504%20(%22Cloudflare%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Fcloudflare-504%20(%22Cloudflare%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Fcloudflare-504%20(%22Cloudflare%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 5 parts, 5 minutes.

1. [Where a Cloudflare 504 comes from 01](#where-a-cloudflare-504-comes-from)
2. [How to get past a 504 as a visitor 02](#how-to-get-past-a-504-as-a-visitor)
3. [504 or 524 or 522: which timeout is it? 03](#504-or-524-or-522-which-timeout-is-it)
4. [What to check and what to send Cloudflare 04](#what-to-check-and-what-to-send-cloudflare)
5. [What it does to SEO 05](#what-it-does-to-seo)

_01_The four sources of a 504 on Cloudflare

## Where a Cloudflare 504 comes from

504 Gateway Timeout is a standard status that the general [504 Gateway Timeout](/errors/http/504) page covers. On Cloudflare, the documentation covers 502 and 504 together: an HTTP 502 or 504 "indicates that Cloudflare is unable to establish contact with your origin web server." There are two possible causes, plus two cases that only look like errors in logs.

Source

### Your origin (most common)

How to recognise it

Cloudflare-branded 504 page: your origin responded with a standard 504

What to do

Ask your host to check the origin answers for the hostname, and look at heavy load, crashes, network failures and timed out or blocked services

Source

### Cloudflare

How to recognise it

Blank page with no Cloudflare branding

What to do

Test compression at the origin; a traffic shift between data centers may also cause brief errors

Source

### Early Hints cache misses

How to recognise it

Many 504s with `ClientRequestSource: earlyHintsCache` in Cloudflare Logs, which Early Hints returns on a cache miss

What to do

Cloudflare calls this expected and benign. These are internal subrequests for cached Early Hints that do not reach your origin

Source

### Workers Cache API misses

How to recognise it

504 in logs with `RequestSource` of `edgeWorkerCacheAPI`, generated when `cache.match` finds content missing or expired

What to do

Cloudflare says these are expected when the cached asset was missing or expired; the Worker sees `undefined`, not a 504

Cloudflare notes you may see 504s in logs or analytics from these two cases. Cloudflare also says Early Hints requests are already filtered out of views such as Cache Analytics, and to exclude them from Log Explorer you can use `ClientRequestSource != "earlyHintsCache"`. Check that visitors actually received a 504 before you chase the origin.

_02_How it works

## How to get past a 504 as a visitor

Cloudflare says that when most [5xx errors](/errors/http/5xx-errors) appear, the right first step is to contact the hosting provider or site administrator, and that Cloudflare Support only assists the domain owner. As a visitor you can do little beyond waiting and ruling out your own setup.

1. 1

### Reload after a minute

If the origin was slow for a moment, a reload may work. Cloudflare says that when a data center gets a sudden increase in traffic, automated processes redirect traffic to another one in a few seconds, and some clients may see temporary latency or 502 errors meanwhile.
2. 2

### Try another network or device

If the page loads on mobile data or on someone else's connection, the problem is local. If it fails everywhere, the site has the fault.
3. 3

### Tell the site owner

Send the exact URL, the time with your timezone and the error code. Cloudflare lists those details for owners to give a hosting provider. Add the Ray ID if the error page shows one, since Cloudflare's log tools can filter by it.

_03_Cloudflare timeouts compared

## 504 or 524 or 522: which timeout is it?

Cloudflare has its own timeout statuses that people often file as 504. The difference is where the wait ended.

Status

### 504

Defined by

HTTP standard

What happened

The origin or Cloudflare returned a gateway timeout; see the sources above

Status

### 522

Defined by

Cloudflare

What happened

Timed out contacting the origin: no SYN+ACK within 19 seconds, or no acknowledgment of the request within 90 seconds after connecting

Status

### 524

Defined by

Cloudflare

What happened

Connected, but no HTTP response within the 125-second Proxy Read Timeout by default

If the status says 522 or 524, use [522](/errors/http/522) or [524](/errors/http/524). They are Cloudflare-defined and not standard HTTP, and their fixes are different from a 504.

If your origin sits behind nginx, the origin may also be where the 504 starts; the nginx-specific checks are on [504 in nginx](/errors/http/504/nginx).

_04_How it works

## What to check and what to send Cloudflare

1. 1

### Look at the error page

Branded means the origin sent it. Blank means Cloudflare did.
2. 2

### Test the origin without Cloudflare

Cloudflare's error 520 guidance suggests setting the affected DNS record to DNS-only or temporarily pausing Cloudflare as a workaround while you troubleshoot. That also shows whether the origin fails on its own.
3. 3

### Check logs between Cloudflare and origin

Cloudflare says the cause is not always in the origin's error logs. Check load balancers, caches, proxies and firewalls too.
4. 4

### Disable compression at the origin

An origin that serves [gzip](/glossary/gzip-compression) content without updating `content-length`, or broken gzip, can produce an unbranded error.

Origin timing check

```
curl -sS -o /dev/null -w 'status=%{http_code} connect=%{time_connect}s total=%{time_total}s\n' \ https://ORIGIN_IP/ -H 'Host: example.com' -k
```

For a support ticket Cloudflare asks for the timestamp with timezone, the URL that returned the error, and the output of `<YOUR_DOMAIN>/cdn-cgi/trace`.

_05_Explained

## What it does to SEO

Google treats 5xx responses as server errors: its crawlers slow down, content returned with them is ignored, and URLs already indexed are kept for a while but eventually dropped if the errors persist. Genuine 504s are 5xx errors to crawlers. See [5xx server errors](/seo-issues/server-errors-5xx) for how to trace the pattern and confirm recovery, and Google's documentation on how [HTTP status codes](/glossary/http-status-codes) affect its crawlers.

Related errors: [Cloudflare redirect loops](/errors/cdn/cloudflare-too-many-redirects), [Heroku H12 request timeout](/errors/cdn/heroku-h12-request-timeout), [Heroku H13](/errors/cdn/heroku-h13), [Heroku H14](/errors/cdn/heroku-h14).

Questions

## Asked a lot.

4 questions people ask next, answered from the sources on this page.

_01_ How do I fix a 504 error on Cloudflare?

Find out whether your origin or Cloudflare sent it by looking at the error page. For an origin 504, check load, crashes and network failures at the origin. For an unbranded one, test disabling compression at the origin.

_02_ Is a 504 error my fault?

Usually not, if you are a visitor. Cloudflare tells visitors to report 5xx problems to the site owner. Owners should start with the origin web server.

_03_ Will a 504 gateway timeout fix itself?

Sometimes. Cloudflare says a brief traffic shift between its data centers can cause temporary latency or 502s. A 504 from a crashed or overloaded origin lasts until the origin is fixed.

_04_ Why do I see many 504s in Cloudflare logs when the site works?

Cloudflare says an influx of 504 responses with a request source of earlyHintsCache is expected and benign when Early Hints is enabled. They are internal subrequests for cached Early Hints, not end user requests.

Sources · 8

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- cloudflare.com
- google.com

1. 01 [Error 502 or 504 - Cloudflare Support docs](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-502-504/) developers.cloudflare.com · checked 2026-10-25
2. 02 [Error 520 - Cloudflare Support docs](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-520/) developers.cloudflare.com · checked 2026-10-25
3. 03 [Error 524 - Cloudflare Support docs](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-524/) developers.cloudflare.com · checked 2026-10-25
4. 04 [Error 522 - Cloudflare Support docs](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-522/) developers.cloudflare.com · checked 2026-10-25
5. 05 [Cloudflare 5xx errors - Cloudflare Support docs](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/) developers.cloudflare.com · checked 2026-10-25
6. 06 [How HTTP status codes affect Google's crawlers](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes) developers.google.com · checked 2026-10-25
7. 07 [Early Hints - Cloudflare Cache docs](https://developers.cloudflare.com/cache/advanced-configuration/early-hints/) developers.cloudflare.com · checked 2026-10-25
8. 08 [Cache API - Cloudflare Workers docs](https://developers.cloudflare.com/workers/runtime-apis/cache/) developers.cloudflare.com · checked 2026-10-25

## Keep learning

[All errors](/errors)

[Learn Cloudflare error 524: a timeout occurred CDN and hosting errors](/errors/http/524) [Related 5xx server errors Status codes and links](/seo-issues/server-errors-5xx) [Read next Cloudflare error 522: connection timed out CDN and hosting errors](/errors/http/522) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 504 errors
[504 Gateway Timeout on IIS](/errors/http/504/iis) [ALB 504 Gateway Timeout](/errors/cdn/alb-504-gateway-timeout) [API Gateway 504 Gateway Timeout](/errors/cdn/api-gateway-504) [504 Gateway Time-out in nginx](/errors/http/504/nginx) [504 Gateway Timeout](/errors/http/504)

More Cloudflare Pages errors
[Cloudflare Pages 404 Not Found](/errors/cdn/cloudflare-pages-404) [Cloudflare too many redirects (ERR_TOO_MANY_REDIRECTS)](/errors/cdn/cloudflare-too-many-redirects) [Cloudflare verify you are human loop](/errors/cdn/cloudflare-verify-you-are-human-loop)

More in CDN and hosting errors
[Akamai reference number](/errors/cdn/akamai-reference-number) [ALB 503 Service Unavailable](/errors/cdn/alb-503) [ALB 504 Gateway Timeout](/errors/cdn/alb-504-gateway-timeout) [API Gateway 403 Forbidden](/errors/cdn/api-gateway-403-forbidden) [API Gateway 504 Gateway Timeout](/errors/cdn/api-gateway-504) [AWS 502 Bad Gateway](/errors/cdn/aws-502-bad-gateway) [AWS Amplify 404 Not Found](/errors/cdn/amplify-404) [AWS EC2: Connection timed out](/errors/cdn/aws-ec2-connection-timed-out) [AWS Lambda 502 Bad Gateway](/errors/cdn/aws-lambda-502) [AWS Lambda timeout](/errors/cdn/lambda-timeout) [Azure Front Door 502](/errors/cdn/azure-front-door-502) [Cloud Run 503 error](/errors/cdn/cloud-run-503) [Cloudflare 504 Gateway Timeout](/errors/cdn/cloudflare-504) [Cloudflare Pages 404 Not Found](/errors/cdn/cloudflare-pages-404) [Cloudflare too many redirects (ERR_TOO_MANY_REDIRECTS)](/errors/cdn/cloudflare-too-many-redirects) [Cloudflare verify you are human loop](/errors/cdn/cloudflare-verify-you-are-human-loop) [CloudFront 400: Bad Request](/errors/cdn/cloudfront-400) [CloudFront 404 Not Found](/errors/cdn/cloudfront-404) [CloudFront 503: Service Unavailable](/errors/cdn/cloudfront-503) [Firebase Hosting 404](/errors/cdn/firebase-hosting-404) [GitHub Pages 404 Not Found](/errors/cdn/github-pages-404) [Google Cloud 502 Bad Gateway](/errors/cdn/google-cloud-502) [Heroku 503 Service Unavailable](/errors/cdn/heroku-503) [Heroku H10: App crashed](/errors/cdn/heroku-h10-app-crashed)

Terms on this page
[Gzip compression](/glossary/gzip-compression) [HTTP status codes](/glossary/http-status-codes)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
