Affected versions: Ubuntu 22.04 LTS

📖 ~1 min read

Table of contents
  1. Symptom & Impact
  2. Environment & Reproduction
  3. Root Cause Analysis
  4. Quick Triage
  5. Step-by-Step Diagnosis
  6. Solution – Primary Fix
  7. Solution – Alternative Approaches
  8. Verification & Acceptance Criteria
  9. Rollback Plan
  10. Prevention & Hardening
  11. Related Errors & Cross-Refs
  12. References & Further Reading

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.

Illustrative mockup for ubuntu-22-04-lts — error_dialog
Nginx upstream socket error produces 502 responses — Illustrative mockup — Progressive Robot

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.

Illustrative mockup for ubuntu-22-04-lts — log_or_config
Corrected php-fpm pool and nginx fastcgi_pass target — Illustrative mockup — Progressive Robot

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 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.