πŸ“– ~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 pages return 502/503 and logs show connect() to unix socket failed (13: Permission denied).

Environment & Reproduction

Ubuntu 16.04 with php-fpm and nginx/apache using Unix sockets after package upgrades or pool config edits.

Root Cause Analysis

Socket file ownership/mode does not permit web server user access, or web server points to wrong PHP-FPM pool socket path.

Quick Triage

Check service status for php7.0-fpm and web server. Inspect socket permissions with ls -l /run/php and confirm configured paths.

Step-by-Step Diagnosis

Review pool settings (listen, listen.owner, listen.group, listen.mode) and corresponding web server upstream config, plus AppArmor denials if present.

Illustrative mockup for ubuntu-16-04-lts β€” ubuntu1604-b01-p20-diagnosis
web server cannot connect to php-fpm socket β€” Illustrative mockup β€” Progressive Robot

Solution – Primary Fix

Align pool socket path and permissions with web server runtime user (www-data), reload php-fpm and web server, and clear stale sockets.

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 ubuntu-16-04-lts β€” ubuntu1604-b01-p20-fix
socket owner/group aligned and requests succeed β€” Illustrative mockup β€” Progressive Robot

Solution – Alternative Approaches

Switch upstream to TCP localhost:9000 style for simpler permission handling, applying firewall/local binding safeguards.

Verification & Acceptance Criteria

PHP pages render normally, no new permission denied socket errors, and health endpoint latency returns to baseline.

Rollback Plan

Restore previous php-fpm pool and web server configuration from backup and restart affected services.

Prevention & Hardening

Template socket settings consistently across environments and verify with post-deploy smoke checks.

Often linked with AppArmor profile denials, stale PID files, or wrong PHP version socket path references.

Related tutorial: View the step-by-step tutorial for Ubuntu 16.04 LTS.

View all Ubuntu 16.04 LTS tutorials on the Tutorials Hub β†’

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

PHP-FPM pool configuration docs, nginx/apache upstream docs, and Ubuntu LEMP/LAMP operational guides.

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.