Cloudflare 524 timeout error displayed on a browser screen
# website errors# troubleshooting# cloudflare

Cloudflare Error 524: A Timeout Occurred

Cloudflare Error 524 means Cloudflare successfully connected to your origin server and sent an HTTP request, but your server didn't respond within 100 seconds.

Cloudflare's proxy has a 100-second timeout. If your server takes longer than that to send back any response, Cloudflare terminates the connection and shows a 524 to the visitor.

How 524 Differs From Other Cloudflare Errors

ErrorWhat happened
521Server refused the TCP connection
522TCP handshake completed, but server didn't respond to HTTP request in time
523Server couldn't be reached at all
524Connected fully, sent request, but no response within 100 seconds

A 524 is specifically about a long-running operation on your server that's taking more than 100 seconds to complete.

What Causes a 524 Error?

Long-Running Database Queries

The most common cause. A complex query, a missing index, or a query scanning a very large table can take minutes. If a web request triggers one of these, the 100-second clock runs out before the query finishes.

Heavy File Processing

File uploads, image resizing, PDF generation, data exports — any operation that processes large files server-side can exceed 100 seconds for big inputs.

External API Calls With No Timeout

If your application makes a request to a third-party API as part of handling a web request, and that external service hangs indefinitely, your server waits and Cloudflare eventually gives up.

Intensive Computation

Machine learning inference, large data transformations, or similar CPU-bound tasks triggered by a web request can easily exceed 100 seconds.

Server Under Heavy Load

A server that's processing too many requests simultaneously can slow down to the point where even simple operations take much longer than usual. Individual queries and processes that are normally fast start queueing up and taking much longer.

How to Fix a 524 Error

Move Long Operations to Background Jobs

This is the right long-term fix for most 524 scenarios. Instead of processing a heavy operation synchronously within the HTTP request:

  1. The web request acknowledges receipt and returns a quick 200 response
  2. The actual processing is queued and handled by a background worker
  3. The user gets a progress indicator or is notified when it's done

This pattern works for file processing, report generation, bulk operations, and any task that doesn't need to complete before the response is sent.

Add Timeouts to External API Calls

If your code calls external services, always set a client-side timeout:

// PHP with cURL
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // 10 second max

// PHP with Guzzle
$client->request('GET', $url, ['timeout' => 10]);
// Node.js with fetch
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 10000);
fetch(url, { signal: controller.signal });

Optimise the Slow Query

Use EXPLAIN in MySQL or PostgreSQL to see how a query is being executed. Missing indexes on large tables are the most common cause of queries that unexpectedly take very long.

EXPLAIN SELECT * FROM large_table WHERE unindexed_column = 'value';

Add an index if needed:

CREATE INDEX idx_column ON large_table (unindexed_column);

Use Cloudflare Workers for Specific Endpoints

For specific endpoints that legitimately need a long time, consider handling the initial request at the Cloudflare Workers level and polling for completion — bypassing the 100-second limit for the origin.

Upgrade to Cloudflare Enterprise

Enterprise plans allow customising Cloudflare's proxy timeout beyond 100 seconds for specific routes. This is a workaround, not a fix — addressing the underlying slow operation is always preferable.

Monitoring for 524 Errors

524 errors mean your site is returning errors to visitors. Even if the underlying cause is a specific slow endpoint rather than a full outage, it affects user experience and SEO.

Domain Monitor detects when your site starts returning errors and alerts you immediately. Pair this with response time monitoring — a gradual increase in response times is often an early warning that a 524 is coming before it actually starts hitting users.

Check out our guide to uptime monitoring best practices for more on building a robust monitoring setup.

More posts

What Is Generative AI? How It Works and What It Creates

Generative AI creates new content — text, images, code, and more. This guide explains how it works, what tools are available, and where it's genuinely useful versus overhyped.

Read more
What Is Cursor AI? The AI Code Editor Explained

Cursor AI is an AI-powered code editor built on VS Code. Learn what it does, how it works, and whether it's the right tool for your development workflow.

Read more
What Is Claude Opus? Anthropic's Most Powerful Model Explained

Claude Opus is Anthropic's most capable AI model, built for complex reasoning and demanding tasks. Learn what it does, how it compares, and when to use it.

Read more

Subscribe to our PRO plan.

Looking to monitor your website and domains? Join our platform and start today.