Software⏱️ 2 min read📅 2026-05-31

How to Fix: nginx error connect to php5-fpm.sock failed (13: Permission denied)

The issue is caused by a permission denied error due to the incorrect ownership of the php5-fpm.sock file. Ensure that the user running nginx has write access to the file and its parent directory.

Quick Answer: Change the ownership of the php5-fpm.sock file to the user running nginx using the command 'chown www:www /var/run/php5-fpm.sock'.

To resolve the 'nginx error connect to php5-fpm.sock failed (13: Permission denied)' issue, you need to ensure that the PHP-FPM process has the correct permissions to access the Unix socket.

🔧 Proven Troubleshooting Steps

Method 1: Chown the Unix Socket

  1. Step 1: Open a terminal and run the command `sudo chown -R www-data:www-data /var/run/php5-fpm.sock` to change the ownership of the Unix socket.

Method 2: Set Correct Permissions

  1. Step 1: Open the nginx.conf file and add the following line to the 'location /' block: `chmod 755 unix:/var/run/php5-fpm.sock;` This sets the permissions of the Unix socket to 755, which allows the PHP-FPM process to access it.

💡 Conclusion

By following these steps, you should be able to resolve the 'nginx error connect to php5-fpm.sock failed (13: Permission denied)' issue and get your PHP-FPM process working again.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions