Skip to main content

How to Troubleshoot Cloudflare Error 524: A Timeout Occurred

Cloudflare Error 524 occurs when the Cloudflare network successfully connects to your origin server, but the server takes longer than 100 seconds to return a valid response. This error is specific to the Cloudflare proxy and indicates that the request...

Cloudflare Error 524 occurs when the Cloudflare network successfully connects to your origin server, but the server takes longer than 100 seconds to return a valid response. This error is specific to the Cloudflare proxy and indicates that the request timed out while waiting for the origin server to complete the process.

Before you begin

You will need:

  • A website currently using Cloudflare as its DNS provider and proxy.

  • Access to your origin server (e.g., via SSH or a control panel).

  • Access to your Cloudflare dashboard.

Check the origin server processing time

The most common cause of a 522 or 524 error is a script or process on your origin server taking too long to execute.

  1. Identify the specific URL or request that triggers the 524 error.

  2. Log into your origin server and check the web server logs (e.g., Apache or Nginx) or your application logs (e.g., PHP-FPM, Python, or Node.js).

  3. Look for the specific request and check the time it took to complete.

  4. If the process takes longer than 100 seconds, the script must be optimized or moved to a background task.

Note: Cloudflare has a hard limit of 100 seconds for the initial response from the origin server. If your application requires more than 100 seconds to process a request (such as a large file export or a complex database query), it cannot be handled through a standard synchronous request.

Check for server-side resource exhaustion

If your server is overloaded, it may be unable to process requests in a timely manner, leading to a timeout.

  1. Check the current CPU and memory usage on your origin server.

  2. Check if the web server or database is hitting its maximum connection limit.

  3. If resources are exhausted, you may need to upgrade your hosting plan or optimize your server configuration to handle more concurrent processes.

Verify the application's backend connection

Sometimes the web server is responsive, but the application is waiting on a backend service, such as a database or an external API.

  1. Test the connection between your web server and your database.

  2. Check if the database is running and has enough available connections.

  3. If your application relies on an external API, verify that the third-party service is responding quickly.

How to handle long-running processes

If your application requires more than 100 seconds to complete a task, you must change how the task is handled to avoid a 524 error.

  1. Use a background worker: Move the long-running task (e.g., generating a large report) to a background queue (such as RabbitMQ, Redis, or a system cron job).

  2. Use AJAX polling: Have the client-side browser send a request to start the process and then poll a different URL to check the status of the task until it is complete.

  3. Use a dedicated worker: Use a separate server or process to handle heavy tasks so they do not block the main web server's ability to respond to Cloudflare.

Confirm the result

  • The website loads successfully without a 524 error.

  • The specific action that previously timed out completes successfully.

Limitations

  • This procedure does not change Cloudflare's 100-second timeout limit.

  • This procedure does not resolve issues where the origin server is completely offline (which typically results in a 522 error).

  • This procedure does not resolve issues where the origin server's firewall is blocking Cloudflare's IP addresses.

Did this answer your question?