Affected versions: CentOS Stream 10

📖 ~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

nginx returns 502 Bad Gateway because it cannot write to the PHP-FPM Unix socket.

Environment & Reproduction

Triggered when listen.owner and listen.group in www.conf do not match the nginx runtime user.

Root Cause Analysis

SELinux or POSIX permissions prevent nginx from connecting to the FPM socket file.

Quick Triage

Inspect /var/log/nginx/error.log and ls -l on the configured socket path.

Step-by-Step Diagnosis

Run: sudo ls -l /run/php-fpm/www.sock; sudo journalctl -u php-fpm; getenforce.

Illustrative mockup for centos-stream-10 — cp249_diag
nginx error log socket permission — Illustrative mockup — Progressive Robot

Solution – Primary Fix

Set listen.owner = nginx and listen.group = nginx in /etc/php-fpm.d/www.conf and reload php-fpm.

Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

Illustrative mockup for centos-stream-10 — cp249_fix
Pool listen.owner and group aligned — Illustrative mockup — Progressive Robot

Solution – Alternative Approaches

Switch to TCP socket on 127.0.0.1:9000 if SELinux complicates Unix socket sharing.

Verification & Acceptance Criteria

nginx serves PHP pages without 502 errors and curl -I returns 200 from a test PHP script.

Rollback Plan

Revert www.conf to apache:apache ownership and restart php-fpm if nginx is removed.

Prevention & Hardening

Document expected listen.owner/group per stack and check after every php-fpm upgrade.

Related to SELinux httpd_can_network_connect booleans and ACL inheritance issues.

Related tutorial: View the step-by-step tutorial for centos-stream-10.

View all centos-stream-10 tutorials on the Tutorials Hub →

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

php-fpm.conf(5) and Red Hat web application guide.

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.