Fpm with ipv6 address

Operating system: Ubuntu
OS version: 20.04.2

I have just installed the latest Virtualmin (LEMP stack | minimal) on a fresh server and added a virtual server with php-fpm (v7.4) as the php execution mode.

The WordPress site on that virtual server is loading fine but I noticed the nginx logs bombarded with errors like the following:

[error] 183472#183472: *625 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xxx.xxx.xx, server: example.com, request: "GET /some-page-name/ HTTP/1.1", upstream: "fastcgi://[::1]:8001", host: "example.com", referrer: "https://example.com/"

On googling about this, I found out from the second answer on this ServerFault thread that it was because I am using an ipv6 address and that I could fix it by replacing localhost with 127.0.0.1 in the nginx server block files since fastcgi://[::1]:8001 won’t work.

I made the changes in /etc/nginx/sites-available/example.com.conf and changed the following line:

fastcgi_pass localhost:8001;

To:

fastcgi_pass 127.0.0.1:8001;

And according to a comment on that same ServerFault answer, in /etc/nginx/sites-available/default, I changed the following line:

listen 80 default_server;

To:

listen 0.0.0.0:80 default_server;

However, after making the above changes and restarting nginx & php7.4-fpm, if I go to Server Configuration > PHP Options, neither FCGId or FPM is selected.

When I choose FPM and click save, the fastcgi_pass 127.0.0.1:8001; line in the nginx server block file reverts back to fastcgi_pass localhost:8001; and the above errors starts showing up again.

The listen 0.0.0.0:80 default_server; wasn’t reverted back on restarting nginx or fpm however.

How do I instruct FPM to use the ipv4 address instead of the ipv6 address?

N.B. I have tried changing listen = /run/php/php7.4-fpm.sock to listen = 127.0.0.1:8000 in /etc/php/7.4/fpm/pool.d/www.conf and then following the above steps but that didn’t help and the same thing happen.

So apparently, the error isn’t because of ipv6 as I initially thought (or maybe still is since the ipv6 alias still exists in etc/hosts). I installed Virtualmin (LEMP | Minimal) on another fresh server which only has an ipv4 address activated for the virtual server and the same error popped up:

[error] 44124#44124: *5 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xx, server: example.com, request: "GET / HTTP/1.0", upstream: "fastcgi://127.0.0.1:8001", host: "example.com"

I’m using the default PHP-FPM settings set by the Virtualmin installation. I’m not sure what is causing this error now.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.