connect() to unix socket failed PHP Origin: Application & API OSI layer 7 · Application Last updated 2 Dec 2026

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.

Exact message you may see 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
Seen on: PHP Nginx

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

  1. Start FPM and check ls -l /run/php/
  2. Match fastcgi_pass unix:/run/php/php8.3-fpm.sock with the pool's listen
  3. Set listen.owner = www-data and listen.group = www-data

Detailed fix by platform

Linux

  1. sudo systemctl status php8.3-fpm && sudo ls -l /run/php/

How to diagnose

  1. Error — 2 or 13?
  2. Service — FPM running?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

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 (Nginx / Apache)414 Request-URI Too L…499 Client Closed Request / client prematurely closed connection — Nginx: [info] client prematurely closed connection while reading response header from upstream / access log status 499 (Nginx / Apache)499 Client Closed Req…accept4() failed (24: Too many open files) — Nginx: [crit] accept4() failed (24: Too many open files) / open() failed (24: Too many open files) (Nginx / Apache)accept4() failed (24:…bind() failed (98: Address already in use) — nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) (Linux)bind() failed (98: Ad…connect() failed (111: Connection refused) while connecting to upstream — Nginx: [error] connect() failed (111: Connection refused) while connecting to upstream, upstream: "http://127.0.0.1:3000/" (Nginx / Apache)connect() failed (111…connect() to unix:/run/php/php-fpm.sock failed (13: Permission denied) — Nginx: [crit] connect() to unix:/run/php/php8.3-fpm.sock failed (13: Permission denied) while connecting to upstream (Nginx / Apache)connect() to unix:/ru…could not build the server_names_hash, you should increase server_names_hash_bucket_size — Nginx: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 64 (Nginx / Apache)could not build the s…directory index of "/var/www/" is forbidden — Nginx: [error] directory index of "/var/www/html/" is forbidden (403 Forbidden) (Nginx / Apache)directory index of "/…connect()…

Explore the map of this error Full error map →

🧠 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.