Cloudflare 524 error when running cron (timeout issue) - Amazon Marketplace Plus
The cron job is failing due to a Cloudflare Error 524. This error occurs when an HTTP request sent through Cloudflare takes longer than Cloudflare’s maximum execution timeout limit (usually 100–120 seconds on standard plans).
Even if a cron task is triggered by your server's scheduler (crontab), executing it via an HTTP URL protected by Cloudflare will cause Cloudflare to drop the connection before the script finishes processing.
Reference: Cloudflare Error 524 Documentation
Why This Happens
The error occurs because:
- The synchronization process is resource-heavy (large catalog, inventory updates, or high order volume).
- Cloudflare enforces a strict timeout on proxied HTTP requests.
- The underlying PHP script may continue executing on your server, but Cloudflare cuts the HTTP connection prematurely.
Method 1: Execute via PHP CLI (Recommended)
The most reliable solution is to run the cron job directly using PHP CLI (Command Line Interface) rather than an HTTP URL. Running in CLI mode completely bypasses Cloudflare, web server timeouts, and HTTP restrictions.
Comparison
- HTTP Version (Causes 524 Timeout):
https://myshop.com/modules/amazonsaas/functions/check_stock.php?cron_token=XXXX&mkp=XXXX&fix=1
- CLI Version (Recommended):
/usr/bin/php /path/to/your/prestashop/modules/amazonsaas/functions/check_stock.php cron_token=XXXX mkp=XXXX fix=1
Instructions for Your Server Administrator:
- Replace the HTTP cron request in
crontabwith the PHP CLI command. - Specify the correct absolute path to your PrestaShop installation directory.
- Verify the correct PHP binary path on your server (e.g.,
/usr/bin/php,/usr/local/bin/php).
Note on CLI Syntax: CLI commands do not use
https://URLs. Parameters are separated by spaces instead of?and&.
Method 2: Bypass Cloudflare via Unproxied Subdomain (Alternative for HTTP Crons)
If your setup strictly requires HTTP-based cron execution and cannot use CLI, Cloudflare does not allow bypassing proxy rules ("Orange Cloud") for specific subfolders on the same domain.
To bypass Cloudflare for HTTP requests, your server administrator can set up a dedicated, unproxied subdomain:
Implementation Steps:
- Create a Dedicated Subdomain: Set up a separate virtual host or subdomain specifically for administrative tasks (e.g.,
bo.myshop.com). - Link the Directory: Point this subdomain directly to your PrestaShop installation or create a symbolic link /
bindmount of the required directory into the subdomain's document root. - Disable Cloudflare Proxy (Grey Cloud): In your Cloudflare DNS control panel, set the DNS record for
bo.myshop.comto DNS Only (Grey Cloud icon instead of Orange Cloud). - Update Cron Endpoint: Trigger your HTTP cron jobs using the unproxied subdomain URL (e.g.,
https://bo.myshop.com/modules/amazonsaas/functions/check_stock.php?...).
Security Warning: Disabling the Cloudflare proxy (Grey Cloud) on a subdomain exposes your origin server's real IP address to anyone who discovers that subdomain name.
Method 3: Upgrade Cloudflare Timeout Limits
If you are on an Enterprise Cloudflare plan, you can request an increased HTTP timeout limit directly through Cloudflare support. However, this is generally not cost-effective or practical for standard hosting setups.
Summary Recommendation
For large product catalogs and frequent synchronization tasks, Method 1 (PHP CLI) is the safest and most efficient solution. It completely eliminates Cloudflare timeouts and prevents real IP exposure associated with unproxied subdomains.
Updated on: 04/08/2026
Thank you!
