# nginx: connect() to unix:/run/php/php8.3-fpm.sock failed (2: No such file or directory / 13: Permission denied) while connecting to upstream

**Code:** `connect() to unix socket failed` · **Category:** PHP · **Seen on:** PHP, Nginx

Nginx cannot talk to PHP-FPM through its socket, so visitors get a 502.

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/php/php-fpm-connect-unix-socket-failed)
