502 Bad Gateway in WordPress
Troubleshoot a WordPress 502 by checking PHP-FPM, overloaded plugins, theme changes, cache/CDN layers, hosting limits, and logs.
Start here
Quick Answer
For WordPress, a 502 usually appears when the gateway cannot get a clean PHP response. Check PHP-FPM status, recent plugin/theme changes, fatal errors, object cache, database health, and host resource limits before repeatedly refreshing the site.
When WordPress causes a 502
WordPress can trigger a 502 when PHP-FPM workers are exhausted, a plugin or theme blocks response generation, a cache/CDN layer points at the wrong origin, or database latency makes PHP stop responding to the gateway. If the error appears after plugin work, compare it with the WordPress 500 path; if nginx is the visible gateway, also check nginx 502 troubleshooting.
Support payload
URL affected:
Time and timezone:
Recent changes:
Error shown:
Does wp-admin load:
Does disabling plugins change it:
Relevant PHP/nginx log lines:
Safer escalation
Do not keep refreshing a checkout, form, or admin action while the backend is overloaded. Capture evidence, disable only the smallest likely plugin or cache layer, and ask the host for PHP-FPM, origin, and database health around the exact timestamp.
Diagnosis
Symptoms
- Public pages or wp-admin show a 502 while static assets may still load.
- PHP-FPM, hosting, or proxy logs mention upstream timeouts or closed connections.
- The problem started after a plugin, theme, cache, PHP, or hosting change.
Common causes
- PHP-FPM pool crashed, reached worker limits, or cannot read WordPress files.
- A plugin or theme triggers a fatal error before PHP returns a response.
- Database or object cache calls stall long enough for the gateway to time out.
- Host-level WAF, CDN, or page cache cannot reach the origin.
Diagnostic Checklist
- Check host and PHP error logs around the failing timestamp.
- Disable cache or security plugins only after taking a backup or snapshot.
- Compare wp-admin, front page, a static asset, and a simple PHP endpoint if available.
- Confirm MySQL and object cache are reachable from the WordPress runtime.
Fixes
Check PHP and WordPress fatal errors first
- 10 minutes
- Risk: medium
- Developer
- WordPress, PHP-FPM
Find the failing plugin, theme, or PHP call before changing gateway timeouts.
- Open PHP, WordPress debug, and hosting error logs.
- Search the timestamp of the 502 for fatal errors, memory exhaustion, or uncaught exceptions.
- If wp-admin is unavailable, use filesystem or database-safe plugin isolation.
- Keep the first fatal error line with file path and plugin/theme name.
You identify the PHP component causing the upstream response to fail.
If logs are empty, move to PHP-FPM worker and gateway logs.
Reload the URL after disabling only the isolated failing component.
Restore the plugin/theme if disabling it does not change the failure.
Reduce PHP-FPM and database pressure
- 20 minutes
- Risk: medium
- Host admin
- WordPress, MySQL
Recover from worker exhaustion, slow database calls, or stalled object cache requests.
- Check PHP-FPM worker usage, memory, and restart loops.
- Check MySQL connection limits, slow queries, and disk pressure.
- Pause abusive imports, cron jobs, backups, or cache-warming jobs.
- Restart only the saturated component after preserving logs.
PHP workers free up, database calls complete, and gateway timeouts stop.
If pressure returns quickly, profile the request or plugin responsible.
Watch PHP-FPM, MySQL, and gateway logs while testing.
Undo temporary limits or disabled jobs after the root cause is fixed.
Platform notes
Many WordPress 502 pages are generated by nginx or a CDN rather than WordPress itself. WordPress logs still matter because PHP may fail before any WordPress HTML is returned.
FAQ
Is a WordPress 502 the same as a WordPress 500?
No. A 500 usually comes from the application response itself. A 502 is generated by a gateway that did not receive a valid upstream response.
Can a plugin cause a 502?
Yes. A plugin can crash PHP, exhaust memory, or trigger a slow external call that causes the gateway to time out.
Review notes
- Last reviewed
- 2026-05-05
- Reviewed by
- FaultForge Editorial Team, Web operations reviewer
- Tested on
WordPress plugin/theme isolation, PHP error log review, wp-config.php checks, nginx/PHP-FPM gateway checks, and managed-hosting escalation paths.