nginx: connect() to unix:/run/php/php8.3-fpm.sock failed (2: No such file or directory / 13: Permission denied) while connecting to upstream
Nginx cannot talk to PHP-FPM through its socket, so visitors get a 502.
connect() to unix socket failedphp-fpm.sock failed No such file or directoryconnect() to unix:/run/php failed (13: Permission denied)502 Bad Gateway php-fpm Meaning
Error 2 means the socket path does not exist (FPM not running or different path). Error 13 means permissions: the nginx user cannot access the socket.
Common causes
- PHP-FPM not running
- Socket path differs from
fastcgi_pass - Socket owner/mode prevents nginx access (
listen.owner,listen.mode) - PHP version upgraded, socket renamed
⚡ Quick fix
- Start FPM and check
ls -l /run/php/ - Match
fastcgi_pass unix:/run/php/php8.3-fpm.sockwith the pool'slisten - Set
listen.owner = www-dataandlisten.group = www-data
Detailed fix by platform
Linux
sudo systemctl status php8.3-fpm && sudo ls -l /run/php/
How to diagnose
- Error — 2 or 13?
- Service — FPM running?
- Path — fastcgi_pass matches listen?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 414 Request-URI Too Large / 400 Request Header Or Cookie Too Large Nginx: 400 Bad Request — Request Header Or Cookie Too Large / client sent too long header line
- 499 Client Closed Request / client prematurely closed connection Nginx: [info] client prematurely closed connection while reading response header from upstream / access log status 499
- accept4() failed (24: Too many open files) Nginx: [crit] accept4() failed (24: Too many open files) / open() failed (24: Too many open files)
Most viewed in PHP
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 2 Dec 2026