Cloudflare returns a 524 when it connected to your origin and sent the request, but your server didn't send back an HTTP response within 125 seconds. The connection worked; the server was too slow.
Quick answer. Something on your server takes too long: a heavy database query, a slow call to another API or a long-running script. Find the slow endpoint and fix it, or move the long work to a background job that answers right away. Only Enterprise plans can raise the 125-second limit.
Is a 524 error my fault?
| Where the problem is | How often |
|---|---|
| Your origin | Yes |
| Cloudflare | Enforces the time limit |
| The visitor | No |
The slow response comes from your origin. Cloudflare only enforces the limit: it waits 125 seconds, then closes the connection and shows 524.
The 524 timeout
Cloudflare's Proxy Read Timeout is 125 seconds by default. Enterprise zones can raise it to 6,000 seconds, with a Cache Rule or with the proxy_read_timeout zone setting; on every other plan it's fixed. The error can show up about a second before or after the limit.
There's a second limit: Cloudflare gets 30 seconds to write the request body to your origin (the Proxy Write Timeout), and nobody can change it. Most 524s come from the read timeout, but a 524 on a large upload can be the write timeout.
Common causes, most likely first
- A slow database query: no index, a full table scan or a report that takes minutes. Check the slow query log and add the index or rewrite the query.
- A call to another API that hangs. If your code waits 130 seconds for a third party, your response can't come back in 125. Set short timeouts on outgoing HTTP calls so a slow dependency fails fast.
- Heavy work inside the request: building a large PDF, processing an upload or running an export while the visitor (and Cloudflare) waits. That work belongs in a background job.
- A starved or deadlocked server. Without CPU, memory or disk I/O, even fast requests crawl, and a deadlock waits forever. Look at resource usage and logs around the times of the errors.
How to fix error 524
Raising the timeout isn't an option on most plans, and a 2-minute page load is broken anyway. The fix is to stop making the visitor wait for slow work.
- Find the slow endpoint with your framework's profiler or Cloudflare's Origin Analytics, which shows response times by path.
- Fix the obvious ones first: add indexes, cache expensive results and set tight timeouts on outgoing API calls.
- For work that's slow by nature, answer at once with
202 Acceptedand a task ID, run the job in a queue (Sidekiq, Celery, BullMQ, SQS) and let the client poll a status endpoint or receive a webhook. - For requests that have to stay long, like large exports, put them on a subdomain that's DNS only in Cloudflare (gray cloud), where the 524 limit doesn't apply.
How a 524 differs from a 522
A 522 means Cloudflare couldn't open the connection at all. A 524 means the connection opened and the request went through, but the answer took too long. A 522 points at firewalls, overload or DNS; a 524 points at slow queries and slow code, so check which one you have before you start.
Catch slow responses before they time out
Endpoints get slower over weeks before they cross 125 seconds. A failover.io HTTP monitor with a timeout of up to 30 seconds fails when a response takes longer, so you hear about a slow path long before visitors see 524s. The monitor's history also shows the response time of every check.
Other Cloudflare 5xx errors
- Cloudflare error 520: Web server returned an unknown error
- Cloudflare error 521: Web server is down
- Cloudflare error 522: Connection timed out
- Cloudflare error 525: SSL handshake failed
- Cloudflare error 526: Invalid SSL certificate
All six codes side by side: Cloudflare 5xx errors explained.
Frequently asked questions
What does Cloudflare error 524 mean?
Cloudflare connected to your origin and sent the request, but the server didn't send back an HTTP response within 125 seconds.
What is the Cloudflare 524 timeout?
125 seconds by default (the Proxy Read Timeout). Only Enterprise zones can raise it, up to 6,000 seconds. A separate 30-second limit applies to sending the request body to your origin, and nobody can change that one.
Can I increase the Cloudflare timeout?
Only on Enterprise, with a Cache Rule or the proxy_read_timeout zone setting. On other plans, make the request faster, move the work to a background job or serve the slow path from a DNS-only subdomain.
What is the difference between error 524 and 522?
With a 522 Cloudflare couldn't open the connection. With a 524 the connection worked and the request went through, but the answer took too long.