Diagnosing a WordPress 502 on a VPS
A 502 means a gateway received an invalid response from an upstream; it does not identify the failed component. Trace the request through the edge and origin, correlate logs and service health, then change only what the evidence supports and verify recovery.
A WordPress 502 is a symptom at a gateway, not a diagnosis of WordPress itself. The response can be generated at an edge service, reverse proxy or web server when communication with an upstream fails. Start by determining which layer returned the response and whether the problem affects every request or only a particular route. Preserve evidence before restarting services or changing configuration.

Map the request and establish scope
Start by identifying the gateway and the affected request scope, then compare evidence from the next upstream. An immediate restart may restore service, but it can erase useful evidence and does not establish the cause.
Write down the path a visitor takes: DNS and any edge proxy, the origin web server, the PHP application process, and the database or external services used by the application. Your installation may combine or omit some layers. A web server can also serve static files without contacting PHP, so a working image does not prove the application path is healthy. Conversely, a failed image does not by itself prove PHP is responsible.
Record the affected hostname, URL, time and timezone, response code, request identifier if available, and whether the problem is continuous. Ask whether logged-in users, anonymous visitors, the admin area or only a specific operation are affected. Compare a representative dynamic page with a known static asset. Avoid repeated checkout, form submission or other state-changing requests while diagnosing; use a harmless request with the site owner's authorization.
A gateway may show its own error page or relay one from another layer. Response headers, edge dashboards and correlated logs can provide clues, but branding alone is not proof of the origin of an error. If a provider offers a documented way to check the origin directly, use it only with authorization and preserve the correct hostname and TLS verification. Do not expose a normally private origin to the internet just to run a test.
| Observation | Possible interpretation | Next evidence |
|---|---|---|
| Edge request fails, origin test succeeds | Edge-to-origin path or edge configuration may differ | Compare timestamp, host and provider logs |
| Static asset works, PHP page fails | Dynamic upstream path deserves investigation | Web server and PHP process logs |
| Several sites fail on one host | Shared service or resource may be involved | Host health and service events |
| Only one route fails | Site code, dependency or request-specific behavior may matter | Correlate route and application errors |
These are hypotheses, not rules. An edge may cache a static asset while the origin is unavailable, and several sites may share a network or database rather than a PHP pool. Keep separate notes for what was observed and what is inferred. If the problem is intermittent, collect multiple examples with timestamps rather than drawing a conclusion from one success.
Why the server label is not a diagnosis
Web infrastructure has many valid configurations. W3Techs' web server survey, viewed 29 November 2026, reports usage among sites whose web server it can identify. A site can use more than one server, so the percentages overlap and do not add up to a market total. An edge server in the survey does not identify the software running at the origin.
Web server usage among identified websites
W3Techs snapshot; a site may use multiple web servers
- Cloudflare Server35.2
- Nginx29.6
- Apache20.2
- LiteSpeed13.0
- Node.js7.8
- Microsoft-IIS2.8
View chart data
| Item | % of identified sites | Note |
|---|---|---|
| Cloudflare Server | 35.2 | |
| Nginx | 29.6 | |
| Apache | 20.2 | |
| LiteSpeed | 13.0 | |
| Node.js | 7.8 | |
| Microsoft-IIS | 2.8 |
These figures describe observed technology usage, not error rates, performance, WordPress installations or the likelihood that a particular server caused an incident. Use the actual configuration and logs for your site. In an Nginx deployment, the Nginx beginner's guide, viewed 29 November 2026, describes both proxying and FastCGI connections; another deployment can have a different topology.
Correlate edge, web server and upstream evidence
Start with the request time and find the corresponding edge and origin access records, if available. Look for the response status and any request identifier that links the layers. Then inspect the web server error log around the same instant. An error about an unavailable socket, a refused connection, an upstream closing a connection or a timeout narrows the next investigation, but the exact message and local configuration matter. Protect logs: request paths, query strings and headers can contain personal data or credentials.
Identify the configured upstream for the affected site before inspecting PHP services. It might be a Unix socket or a network listener, and a server can run several PHP versions or pools. Check the status and recent journal of the relevant service using your operating system's normal read-only tools. For example, an administrator may use systemctl status <actual-service> and journalctl -u <actual-service>, substituting the verified unit name. These commands require appropriate permissions and service names vary by distribution.
If the service is running, check whether the configured socket or listener exists and whether the web server is permitted to connect. A running process alone does not prove that the correct pool accepts requests. Compare configuration with the deployed site, rather than changing permissions broadly. Look for recent deploys, package upgrades or configuration changes that coincide with the first failure. Avoid publishing socket paths, secret values or complete logs in public support channels.
Check application and host constraints
If the upstream accepts connections but the dynamic request fails, inspect PHP and application errors at the matching time. A plugin, theme, custom code or external dependency can fail during a particular request. Check the recent change history and use a staging copy or an approved reversible isolation procedure to investigate. Disabling extensions on production can change customer behavior, so agree on impact and recovery before doing it.
Also inspect disk space, inode availability, memory pressure and relevant service limits with read-only host tools such as df -h and df -i. A full filesystem may affect logging, sessions or other operations; memory pressure can affect processes. These conditions are leads, not proof of the cause of a 502. Correlate them with service events and measurements. Do not delete unknown files or increase resource limits without understanding the workload and capacity.
Database connectivity and slow queries may contribute to application failures, but the observed status and timeouts depend on the stack. A gateway timeout and a bad gateway response are distinct outcomes, and one should not be assumed from the other. Check database health and application logs using the account and access approved for the incident. Do not run repairs or destructive queries simply because the database is present in the request path.
Recover with controlled changes
Agree on an incident owner, a communication channel and a stopping condition. Capture relevant logs and configuration before changing anything. Choose the smallest supported correction indicated by evidence, such as reverting a recent incorrect upstream configuration or restoring a service that stopped, after understanding why it stopped. Validate configuration before a reload and follow the distribution or hosting provider's documented procedure. A restart may restore service temporarily while erasing useful transient evidence; it is not a root-cause analysis.
If a deployment introduced the failure, assess rollback against database changes and any orders or edits received since the recovery point. A file rollback may be insufficient after a schema migration; restoring an older database can lose legitimate writes. Consult the backup scope guide and coordinate a recovery decision with the site owner. Never restore a production backup into an exposed test environment.
A suspected security compromise requires a different response from routine troubleshooting. Preserve evidence, restrict access as directed by the incident owner and rotate affected credentials using the organization's process. Do not assume that a successful restart or an old backup removes the cause. In every case, avoid exposing private service ports or weakening access controls to make the error disappear.
Verify and prevent recurrence
After the change, repeat the same harmless request through the normal visitor path and confirm the expected response. Test representative dynamic pages, login and a safe business workflow; check the origin and edge logs for fresh errors. Observe for recurrence over a period appropriate to the failure pattern. A single successful request does not establish that an intermittent issue is resolved.
Record the affected scope, timestamps, evidence, change, observed result and remaining uncertainty. Add monitoring for the failed dependency where practical, including alerts that reach a person who can act. Review capacity, deployment safeguards and recovery procedures based on the actual cause. If the root cause is not known, say so and retain the evidence rather than turning a guess into a permanent runbook instruction.
Where Cloudflare is in the request path, its 502 and 504 guidance (viewed 29 November 2026) distinguishes errors returned by the origin from errors arising at the edge and recommends collecting the affected URL and timestamp. In a PHP-FPM deployment, the PHP-FPM manual (viewed the same date) describes the pool listener and pm.max_children, which limits simultaneous requests served by the pool. Check whether the relevant pool is saturated and whether memory permits a change; increasing the limit blindly can worsen pressure. For Nginx FastCGI connections, Nginx documents the read timeout as the interval between successive reads, not a total request duration. Investigate the slow or failing upstream before changing timeout values.
Sora Panel is not released yet. Read how it works on the homepage and explore the Guides.
Frequently asked questions
Does a 502 prove WordPress itself is broken?
No. Identify the responding gateway and correlate evidence across the request path before attributing the failure.
Should I restart PHP immediately?
First preserve relevant evidence and identify the actual upstream. A restart can temporarily restore service while hiding the underlying cause.
Why does a static image work while a WordPress page fails?
The static asset may be served from a cache or web server without using the failing dynamic application path. Check the actual request chain.
Is a 502 the same as a 504?
No. They are different gateway responses; use the actual status and corresponding logs to investigate rather than treating them interchangeably.
Sources
- W3Techs web server survey (viewed 2026-11-29)
- Nginx beginner's guide (viewed 2026-11-29)
- Cloudflare 502 and 504 troubleshooting (viewed 2026-11-29)
- PHP-FPM configuration (viewed 2026-11-29)
- Nginx FastCGI module (viewed 2026-11-29)
Sora Panel is not released yet. Read how it works on the homepage.