PHP-FPM
php-fpm.sock
troubleshooting
configuration
web server setup

How to find the php-fpm.sock socket path

Codemia Knowledge Hub ·

Read the listen directive in the PHP-FPM pool configuration your web server uses, then check that the socket file exists and that the web server can access it. The path is not universal: it depends on the pool configuration and the Linux distribution.

Socket or TCP port

PHP-FPM can listen on:

  • a Unix socket, such as /run/php/php8.2-fpm.sock
  • a TCP address, such as 127.0.0.1:9000

If the pool uses TCP, there is no .sock file to find, so confirm this first. The listen setting decides it, usually in a pool file such as www.conf.

Searching the configuration for listen

bash
grep -R "^listen\s*=" /etc/php /etc/php-fpm* 2>/dev/null

Typical results:

text
/etc/php/8.2/fpm/pool.d/www.conf:listen = /run/php/php8.2-fpm.sock

or:

text
/etc/php-fpm.d/www.conf:listen = /run/php-fpm/www.sock

That line is the authoritative answer. Do not guess the path from a blog post or another server.

Where pool files live

  • Debian and Ubuntu: often /etc/php/<version>/fpm/pool.d/
  • RHEL, CentOS, AlmaLinux and Rocky: often /etc/php-fpm.d/
  • some custom builds: under /usr/local/etc/

The main configuration may include several pool files, so check the pool for the site you are configuring.

Checking that the socket exists

bash
ls -l /run/php/php8.2-fpm.sock

If the file is missing, PHP-FPM may not be running or may have failed to start. Check the service status and logs:

bash
systemctl status php8.2-fpm
journalctl -u php8.2-fpm --no-pager -n 50

Use the service name for the PHP version installed on your system.

Cross-checking the effective configuration

Some PHP-FPM builds can print the parsed configuration, which helps when includes and overrides make the layout confusing:

bash
php-fpm8.2 -tt 2>&1 | grep listen

The binary may be called php-fpm or php-fpm8.1 on other systems. Either way, you are looking at the listen values PHP-FPM actually uses.

Pointing Nginx or Apache at the same socket

The web server must use the same endpoint. For Nginx, the key directive is usually:

nginx
1location ~ \.php$ {
2    include fastcgi_params;
3    fastcgi_pass unix:/run/php/php8.2-fpm.sock;
4    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
5}

If PHP-FPM listens on TCP, fastcgi_pass must point to that TCP address instead.

For Apache with proxy_fcgi, the configuration must reference the same backend endpoint. A mismatch between the web server and the pool configuration is one of the most common causes of 502 Bad Gateway and No such file or directory errors.

Socket permissions

The web server user must be allowed to use the socket. Check the pool settings listen.owner, listen.group and listen.mode. If Nginx runs as www-data but the socket belongs to another user with restrictive permissions, the path exists but requests still fail.

Mistakes to avoid

  • Assuming a .sock file must exist. A pool listening on 127.0.0.1:9000 has none.
  • Editing the wrong pool file. Many systems have several pools, and the site may not use www.conf at all.
  • Searching only the filesystem. PHP-FPM recreates sockets at startup, so the configured listen path is more trustworthy than a stray file left over from an older setup.
  • Stopping at the path. A correct socket location does not help if PHP-FPM is down or the permissions are wrong.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Interview Questions practice on Codemia

Over 11,000 interview practice questions for 300+ companies, searchable by company and role.

Browse interview questions