π ~1 min read
Table of contents
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.

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.

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.
Related Errors & Cross-Refs
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.