connect() failed (111: Connection refused) while connecting to upstream, client ….

by Yuji

If you are getting this error suddenly and intermittently, this may be due to issues resolving localhost intermittently, perhaps intermittently when attempting IPv6 vs IPv4.

I was able to solve the problem by changing my references to localhost to in my nginx configs.