How to find my php-fpm.sock?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
The location of php-fpm.sock is not universal because it depends on your PHP-FPM pool configuration and Linux distribution. The reliable way to find it is to inspect the listen directive for the pool your web server uses, then verify that the socket file exists and that the web server can access it.
Understand What You Are Looking For
PHP-FPM can listen in two different ways:
- a Unix socket such as
/run/php/php8.2-fpm.sock - a TCP address such as
127.0.0.1:9000
If your pool is configured for TCP, there is no .sock file to find. That is the first thing to confirm before you go searching the filesystem.
The setting that decides this is named listen and usually lives in a pool file such as www.conf.
Search The Configuration First
Start by grepping the PHP-FPM configuration directories for listen lines.
Common results look like this:
or:
That line is the authoritative source. Do not guess the path from a blog post or from another server.
Common Pool File Locations
Different distributions place the files in different directories:
- Debian and Ubuntu often use
/etc/php/<version>/fpm/pool.d/ - RHEL, CentOS, AlmaLinux, and Rocky often use
/etc/php-fpm.d/ - some custom builds keep everything under
/usr/local/etc/
The main service file may include many pool files, so check the pool that matches the site you are configuring.
Verify The Socket Exists
After you find the configured path, check whether the file is actually present.
If the socket does not exist, PHP-FPM may not be running or the service may have failed to start. Inspect service status and logs:
Replace the service name with the version installed on your system.
Use The Running Configuration As A Cross-Check
Some PHP-FPM builds can print the parsed configuration, which is useful when includes and overrides make the file layout confusing.
On other systems the binary might be php-fpm or php-fpm8.1. The goal is the same: inspect the effective listen settings as PHP-FPM sees them.
Match Nginx Or Apache To The Same Endpoint
Once you know the actual socket path, make sure the web server uses the same value.
For Nginx, the important directive is often:
If PHP-FPM listens on TCP instead, fastcgi_pass should point to the TCP address instead of a Unix socket.
For Apache with proxy_fcgi, the equivalent configuration also needs to reference the same backend endpoint. A mismatch between web server config and PHP-FPM pool config is one of the most common causes of 502 Bad Gateway or No such file or directory errors.
Permissions Matter Too
Finding the socket is only half the job. The web server user must also be allowed to use it.
Check the pool settings named listen.owner, listen.group, and listen.mode. If Nginx runs as www-data but the socket is owned by another user and has restrictive permissions, the path may exist but still fail at runtime.
Common Pitfalls
The first pitfall is assuming there must be a .sock file. If the pool listens on 127.0.0.1:9000, no socket file will exist.
Another mistake is editing the wrong pool file. Many systems have multiple pools, and the site may not use www.conf at all.
People also search only the filesystem and not the configuration. Since PHP-FPM recreates sockets at startup, the configured listen path is more trustworthy than a stray file left behind from an older setup.
Finally, do not stop after finding the path. A correct socket location is still useless if PHP-FPM is down or the permissions are wrong.
Summary
- Find the
listendirective in the active PHP-FPM pool configuration. - Confirm whether the pool uses a Unix socket or a TCP port.
- Verify that the configured socket file actually exists while PHP-FPM is running.
- Make sure Nginx or Apache points to the same backend endpoint.
- Check socket ownership and mode if the path exists but requests still fail.
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 courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.