🔧 Error Fixes
· 1 min read

Cloudflare: Error 524 Timeout — How to Fix It


Cloudflare Error 524 means Cloudflare connected to your origin server, but the server didn’t respond with an HTTP response within 100 seconds.

What causes this error

  1. Slow origin server — your app takes too long to process the request
  2. Long-running process — file uploads, report generation, database migrations
  3. Origin server overloaded — too many requests, not enough resources

Fix 1: Optimize the slow endpoint

Check which endpoint is timing out and optimize it:

  • Add database indexes for slow queries
  • Move heavy processing to background jobs
  • Cache expensive computations

Fix 2: Increase Cloudflare timeout (Enterprise only)

Enterprise plans can increase the proxy read timeout up to 600 seconds. Free/Pro/Business plans are fixed at 100 seconds.

Fix 3: Use background processing

For long-running tasks, return a 202 Accepted immediately and process in the background:

app.post("/generate-report", (req, res) => {
  const jobId = startBackgroundJob(req.body);
  res.status(202).json({ jobId, status: "processing" });
});

app.get("/job/:id", (req, res) => {
  const status = getJobStatus(req.params.id);
  res.json(status);
});

Fix 4: Bypass Cloudflare for long requests

Use a subdomain that’s not proxied through Cloudflare (grey cloud in DNS settings) for endpoints that legitimately take over 100 seconds.

Related: Nginx: 504 Gateway Timeout fix · Vercel Serverless Timeout fix · Cloudflare Workers vs Vercel Edge