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

12,081

Solution 1

I hit the same problem, in my case, it was the firewall port which needed to be opened.

Please check your firewall / a firewall ahead of your machine that could be refusing the connection.

Solution 2

Check if your upstream address works correct (in your case 108.166.94.94:7080/assets/js/msgFBmodal.js). If everything fine then try to see packets from nginx to upstream for example like this

sudo ngrep -q -d eth0 -W byline port 7080
Share:
12,081
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    Can't figure out why I keep getting 502 bad gateway nginx error.

    Here is the error from nginx error log.

    2012/12/03 19:30:21 [error] 20650#0: *939328 connect() failed (111: Connection refused) while connecting to upstream, client: 70.94.18.35, server: demo.domain.com, request: "GET /assets/js/msgFBmodal.js HTTP/1.1", upstream: "http://108.166.94.94:7080/assets/js/msgFBmodal.js", host: "demo.domain.com", referrer: "http://demo.domain.com/register/user_profile"
    

    I'm on a rackspace cloud sever, CentOS.