Queation: Wordpress website admin page shows 502 Bad Gateway: php-fpm.sock failed (2: No such file or directory)
Applicable to:Symptoms
- A WordPress website shows 502 Bad Gateway only when example.com/wp-admin or example.com/wp-login.php is accessed
- In the PHP Settings for the domain in Plesk, it is visible that the website is set to run PHP as a FastCGI application served by Apache
/opt/plesk/php/X.X/etc/php-fpm.d does not contain a config file for example.com, because the domain is not set to
run PHP as an FPM application served by Apache
The following error is shown in /var/www/vhosts/system/example.com/logs/proxy_error_log log file:
# tail -f /var/www/vhosts/system/example.com/logs/proxy_error_log
...
[crit] 3003#0: *635755 connect() to unix:///var/www/vhosts/system/example.com/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 213.21.0.10, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/example.com/php-fpm.sock:", host: "example.com"
CauseA plugin or theme in the WordPress script requires an existing php-fpm.sock file, however when
PHP runs as a FastCGI application served by Apache, such a file is not generated and it is therefore expected for it to be missing. This means that this specific website is only able to work properly when
PHP runs as an FPM application served by Apache.Resolution
1.Log into Plesk
2.Go to
Domains > example.com > PHP Settings3.Set the used PHP handler to
run PHP as FPM application served by Apache via the dropdown
4.Scroll down and press
Apply