Home / WordPress / 504 Gateway Timeout in WordPress: Fix

504 Gateway Timeout in WordPress: Fix

Resolve 504 timeouts by identifying slow requests, tuning PHP limits, and optimizing plugins.

Views: 21 Unique: 17 Updated: 2026-03-16

What this problem is

You get a 504 Gateway Timeout from the server, CDN, or reverse proxy.

Why it happens

  • A request takes too long (slow database or external API)
  • Long-running admin actions (imports, backups)
  • PHP-FPM/Apache timeouts

Prerequisites

  • Access to logs or performance monitoring (recommended)
  • Ability to disable plugins temporarily

Diagnosis

  1. Check whether 504 happens only on specific pages or actions.
  2. Review error logs for timeouts and the slow script/plugin.
  3. Test with all non-essential plugins disabled.

Step-by-step (detailed)

  1. Increase PHP execution time and memory limit if allowed.
  2. Optimize database (clean autoload options, transients).
  3. Replace or configure heavy plugins.
  4. If using a CDN/proxy, adjust timeout settings when possible.

Expected results

  • Admin actions complete without timeouts
  • Fewer 504 responses

What to do if it fails

  • Ask hosting support for server timeout values and logs.
  • Split big tasks into smaller batches (imports, bulk edits).
  • Upgrade plan if the site is consistently at the limit.

Best practices

  • Run heavy jobs with WP-CLI when possible.
  • Use optimized hosting and a CDN.
  • Monitor slow queries regularly.
Back to category