I'm setting up a web server. I have a freshly installed Ubuntu 22.04, nginx (welcome page works), and php-fpm which installed php8.1 and php-fpm8.1.

To test PHP, I created a /var/www/<my domain>/info.php which just includes:

phpinfo(); ?>

Browsing to this page gives Error 502 - Bad Gateway.

Checking /var/log/nginx/error.log shows this:

connect() to unix: /var/run/php/php7.4-fpm.sock failed (2: No such file or directory)

I verified that /var/run/php contains php8.1-fpm.sock but indeed not php7.4-fpm.sock

What is causing the request to look for php7.4? How can I fully configure 8.1 so as not to be reliant on old/multiple versions of php?

1 Answer 1


You need to configure the path of the fpm php module to use in /etc/nginx/sites-available/default config file:

location ~ \.php$ {
    # Nginx php-fpm sock config:
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;

So edit "/etc/nginx/sites-available/default" and change from

fastcgi_pass unix:/run/php/php7.4-fpm.sock;


fastcgi_pass unix:/run/php/php8.1-fpm.sock;

and restart nginx

  • Thank you, this worked! The issue was that I copied a tutorial that used the 7.4 path in the config file.
    – Wiley Rush
    Dec 3, 2022 at 23:46
  • @WileyRush Please consider marking the answer as accepted if it solved your issue. Dec 7, 2022 at 11:28
  • Done! Sorry, didn't realize I had unlocked that ability.
    – Wiley Rush
    Dec 7, 2022 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.