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
- Check whether 504 happens only on specific pages or actions.
- Review error logs for timeouts and the slow script/plugin.
- Test with all non-essential plugins disabled.
Step-by-step (detailed)
- Increase PHP execution time and memory limit if allowed.
- Optimize database (clean autoload options, transients).
- Replace or configure heavy plugins.
- 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.