Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx: connect() failed (111: Connection refused) while connecting to upstream - after update nginx -

After update nginx to version 1.19 my web server stop to work.

I am getting 502 gateway timeout error in browser when i was sending the request through browser

when i checked the nginx error log, i got this error

2021/03/24 06:25:50 [error] 56837#56837: *7775 connect() failed (111: Connection refused) while connecting to upstream, client: 85.208.98.19, server: bienestarmutuo.org, request: "GET /ten-principles-of-the-new-education/ HTTP/1.1", upstream: "fastcgi://10.64.10.43:8050", host: "mutualwelfare.org"
like image 869
Elisha Bentzi Avatar asked Oct 11 '25 16:10

Elisha Bentzi


1 Answers

After many hours trying to find the source of the problem (many install and purge)

The problem was, for me, the use of different port "name" in nginx and php.

in php (/etc/php/8.0/fpm/pool.d/bienestarmutuo-org8050.conf) i have

listen = localhost:8050

in nginx (/etc/nginx/sites-available/bienestarmutuo.org.conf) i have

fastcgi_pass 10.64.10.43:8050;

This was changed to:

in nginx

fastcgi_pass 127.0.0.1:8050;

in php

listen = 127.0.0.1:8050

restart php and nginx, everything Work again.

note: use of 127.0.0.1 instead of localhost, save an DNS lookup.

the solution for me, was use the same reference for the ip:port in both php and nginx -> 127.0.0.1

like image 138
Elisha Bentzi Avatar answered Oct 14 '25 06:10

Elisha Bentzi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!