Your application did not send an HTTP response within Cloudflare's allotted time.
The Cloudflare 524 "A Timeout Occurred" error indicates that Cloudflare successfully established a TCP connection with your server, but your application did not send a complete HTTP response in time. On Cloudflare Free through Business plans, this timeout is fixed at 100 seconds and cannot be modified.
Unlike errors 521, 522, and 523 which are connectivity problems, 524 is an application problem: your code takes too long to execute. This can be due to slow PHP scripts, unoptimized database queries, blocking external API calls, or batch processes that are too large.
This guide explores the causes of 524, profiling techniques to identify bottlenecks, and architectural patterns (async processing, webhooks) for handling long operations without triggering timeouts. The goal is to keep all your web responses under 100 seconds.
The 524 timeout occurs when your application exceeds 100 seconds of processing:
Identifying which part of your code exceeds the timeout requires profiling:
The approach depends on the nature of the timing-out operation:
Here is a PHP pattern to transform a long operation into async processing:
file('csv');
// Create job with "pending" status
$job = ImportJob::create([
'file_path' => $file->store('imports'),
'status' => 'pending',
'user_id' => auth()->id(),
]);
// Dispatch to queue (non-blocking)
dispatch(new ProcessImport($job));
// Return immediately
return response()->json([
'job_id' => $job->id,
'status_url' => url("/api/import/{$job->id}/status"),
], 202); // 202 Accepted
}
// Endpoint to check status
public function checkStatus(string $jobId): Response
{
$job = ImportJob::findOrFail($jobId);
return response()->json([
'status' => $job->status, // pending, processing, completed, failed
'progress' => $job->progress_percent,
'result_url' => $job->status === 'completed' ? $job->result_url : null,
]);
}
This pattern immediately returns a 202 code with a job ID. The client can then poll the status endpoint to track progress. When the job completes, the result is available. This pattern avoids any Cloudflare timeout.
Adopt these best practices to avoid timeouts:
Not on Free, Pro, and Business plans. Only the Enterprise plan allows increasing the timeout up to 6000 seconds. The recommended solution is to optimize your application or switch to async processing.
In Cloudflare analytics, filter by HTTP code 524 to see affected URLs. You can also enable response time logging in Nginx to identify long requests server-side.
Yes, 202 Accepted means "request accepted for processing but not yet complete". It's the standard HTTP code for async operations. Provide a status URL so the client can track progress.
Implement a retry system with exponential backoff. Mark the job as "failed" after N attempts and notify the user. Log errors for investigation.
Cloudflare Workers have their own CPU limit (50ms on free plan), they're not suited for long operations. They're useful for edge computing, not for bypassing origin timeouts.
Yes, configure an alert on response time. If your endpoint usually takes 5 seconds and rises to 50 seconds, MoniTao alerts you before reaching Cloudflare's 100 seconds.
Cloudflare error 524 is a signal that your application has operations exceeding the 100-second timeout. Unlike other Cloudflare 5xx errors which are infrastructure problems, 524 requires code changes: optimization, chunking, or switching to async processing.
The recommended pattern for long operations is to immediately return a 202 code with a job ID, process in the background, and allow the client to check status. Combined with MoniTao monitoring that alerts on high response times, you can prevent 524 errors before they impact your users.
Start free, no credit card required.