Troubleshooting guide · website-errors · Published 2026-08-16 · 3 min read

WordPress cron requests returning 502

Diagnose WordPress cron 502 bad gateway errors from PHP timeouts, web server limits, and overlapping cron runs.

How WordPress cron fails with a 502

WordPress does not run a real operating-system scheduler. When someone visits the site, wp-cron.php runs at the request edges and processes events that are "due". Each visit can trigger a run of overdue jobs in that same HTTP request. That is the key fact for a 502: the visitor's request is also the cron worker, so a slow job can push the whole request past the gateway timeout (nginx timeout 60, or the PHP-FPM request_terminate_timeout), and the upstream returns 502 for the page and every cron job it tried to run.

Signs you are dealing with cron 502s

Because cron is fired by visitors, a site with low traffic can go for days between successful runs, then throw a pile of jobs at one unlucky request and 502 only at that moment. The failure is a schedule, not a page.

Find the failing job

  1. Lock the log window: add a marker to see the request edge, or view the PHP-FPM slow-log which already records requests that exceed request.slowlog_timeout.
  2. Check the events queue from WP-CLI:
wp cron event list --status=due --fields=hook,schedule,next_run_relative
  1. Identify which hooks fire at the failing time. The usual suspects are long HTTP drives inside a cron event: an external API fetch, a large email blast, an image resize loop, or a plugin health-check that calls an API endpoint per site.
  2. Confirm the timeout value in your stack so you know what "too slow" means here: max_execution_time for PHP, request_terminate_timeout for PHP-FPM, and the gateway timeout for nginx.

Fix the batch

  1. Spread the load. wp config set DISABLE_WP_CRON true --raw and add a real system cron that hits wp-cron.php at 5-minute intervals with curl --max-time 55. Then fast requests stop mounting.
  2. Raise the right timeout for the job, not the site. If a rebuild job needs 300 seconds, raise the PHP maximum for the CLI job only; do not set the web max_execution_time to 300. For media-heavy jobs, wp media regenerate from CLI is the safe route instead of the in-browser AJAX.
  3. Split the job. Break a giant loop into an event that re-queues itself (wp_schedule_single_event) per chunk, so each run stays well under the timeout.
  4. Plug memory leaks. A 502 during cron frequently sits next to memory_limit exhaustion in the log; the loop that failed is the loop that grows. Fix that first, then raise memory.
  5. Verify in isolation. wp cron event run <hook> runs exactly one event and returns before the gateway; then retest with a curl against wp-cron.php.

Prevention

The 502 error overview is the broader path to the same gateway limit, and the 504 walkthrough explains the upstream timeout that a slow cron run trips.

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services