Common causes
- PHP-FPM is stopped or failed to start (check its own config errors)
- PHP was upgraded (for example 8.1 to 8.3) and the socket name changed, but fastcgi_pass still points to the old one
- Nginx uses a generic name like php-fpm.sock while the pool listens on php8.3-fpm.sock, or vice versa
- On RHEL/Alma/Rocky the pool listens on /run/php-fpm/www.sock or 127.0.0.1:9000, not /run/php/
- The pool listens on TCP 127.0.0.1:9000 while Nginx expects a socket
- A related variant (13: Permission denied) means the socket exists but listen.owner/listen.group do not allow the Nginx user
How to fix it
- Check PHP-FPM is running. Run systemctl status php8.3-fpm (or php-fpm on RHEL). If it failed, run sudo php-fpm8.3 -t to find config errors, then start it.
- Find the real socket path. Run grep -R "^listen" /etc/php/*/fpm/pool.d/ (or /etc/php-fpm.d/) and ls -l /run/php/ to see which sockets actually exist.
- Update fastcgi_pass. Edit the server block so fastcgi_pass matches the listen value exactly, for example unix:/run/php/php8.3-fpm.sock. Search all files with grep -R fastcgi_pass /etc/nginx/.
- Fix socket permissions if you see error 13. In the pool config set listen.owner and listen.group to the Nginx user (www-data on Debian/Ubuntu, nginx on RHEL) and listen.mode = 0660, then restart PHP-FPM.
- Test and reload. Run sudo nginx -t && sudo systemctl reload nginx, then load a PHP page and check the error log is clear.
Nginx + PHP-FPM pool
# /etc/nginx/sites-available/example.com
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
; /etc/php/8.3/fpm/pool.d/www.conf
listen = /run/php/php8.3-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660 How to stop it happening again
- Update fastcgi_pass in the same step as any PHP version upgrade
- Enable PHP-FPM with systemctl enable so it starts on boot
- Keep the socket path in one shared snippet included by all sites