📖 ~1 min read
Table of contents
Symptom & Impact
Dynamic PHP pages fail with 502 Bad Gateway, impacting customer-facing applications.
Environment & Reproduction
Common after php-fpm version changes or pool path modifications.
Root Cause Analysis
Nginx points to stale unix socket or php-fpm service is down, so upstream handoff fails.
Quick Triage
Check php-fpm socket existence and service state immediately.
Step-by-Step Diagnosis
Match nginx fastcgi_pass value to active php-fpm socket and inspect pool logs.

Solution – Primary Fix
Start php-fpm, align nginx upstream socket path, test config, then reload services.
Still having issues? Our Server Management team can diagnose and resolve this for you. Get in touch for a free consultation.

Solution – Alternative Approaches
Use TCP upstream (127.0.0.1:9000) for environments where socket path management is brittle.
Verification & Acceptance Criteria
Application endpoints return 200 and logs no longer show connect() to unix socket errors.
Rollback Plan
Revert nginx site config to previously working php-fpm endpoint and reload.
Prevention & Hardening
Pin PHP versions during maintenance and include post-upgrade socket validation checks.
Related Errors & Cross-Refs
Related to permission-denied on socket files and exhausted php-fpm worker pools.
Related tutorial: View the step-by-step tutorial for Ubuntu 22.04 LTS.
View all Ubuntu 22.04 LTS tutorials on the Tutorials Hub →
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
Nginx and php-fpm integration documentation for Ubuntu 22.04.
Need Expert Help?
If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today — we respond within one business day.