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
Typical results:
or:
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
If the file is missing, PHP-FPM may not be running or may have failed to start. Check the service status and logs:
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:
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:
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
.sockfile must exist. A pool listening on127.0.0.1:9000has none. - Editing the wrong pool file. Many systems have several pools, and the site may not use
www.confat all. - Searching only the filesystem. PHP-FPM recreates sockets at startup, so the configured
listenpath 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.
Related reading
- How to find MySQL process list and to kill those processes?
- How to find out if a Timer is running?
- How to find out which version of the .NET Framework an executable needs to run?
- How to find the Git commit that introduced a string in any branch?
- How to find the reason for a failed Build without any error or warning
- How to find the root cause of high CPU usage of Kafka brokers?
- How to find the root cause of spontaneous restarts of Puma Worker?
- How to find windows service exe path
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo 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 courseInterview Questions practice on Codemia
Over 11,000 interview practice questions for 300+ companies, searchable by company and role.