Problem is successfully solved!
In file /etc/php/7.1/fpm/pool.d/www.conf it was not spelled out listen = 127.0.0.1:9000, was spelled only listen = /run/php/php7.1-fpm.sock.
Thank you for paying attention to my topic. Below I posted the answer.
As far as I remember, in earlier versions it was written listen = 127.0.0.1:9000.
Hmm, not quite what I meant. See listen.owner and listen.group in pool.d - in combination with the default listen.mode of 0660, a process can’t read from /run/php/php7.1-fpm.sock unless its user or group is www-data.
That means Caddy itself - not PHP - needs to be run as www-data (or root), or it won’t be able to read from the socket (and it will timeout, generating 502s).
I see that comment ;listen.mode = 0660, may be it is problem…
Or change settings on my home user…
I also tried to run the Caddy from different users.
Cheers!
Problem solved, the socket works!
I have deleted comment out listen = 127.0.0.1:9000.
Switched to user www-data using sudo -su www-data, then run caddy command caddy.
You were right!