Php-fpm errors (IPv6)

Operating system: Ubuntu
OS version: 20.04

Hi, I’m having an issue with the latest version of Ubuntu 20.04 and Virtualmin with LEMP stack. In Nginx error log there’s lines:

... connect() failed (111: Connection refused) while connecting to upstream, client: xxx, server: test.example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://[::1]:9001" ...

This seems to happen because fpm is listening localhost. If I change the pool and nginx proxy settings from localhost to 127.0.0.1 the issue disappears. I just couldn’t find any place set configure these automatically for new servers.

The error is only in the logs, no 5xx responses.

Here’s a related thread I found: Puzzling Log messages talking to php-fpm
And a reply: Puzzling Log messages talking to php-fpm

Another option that seemed to work was disabling IPv6 completely, which obviously is not ideal.

On CentOS 8 there was a similar case, but there was just a warning in fpm logs:

WARNING: Found multiple addresses for localhost, 127.0.0.1 ignored

Any insight on this or just ignore it?