Nathan
Nathan

Reputation: 31

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

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.

Upvotes: 2

Views: 13524

Answers (4)

Chris Wood
Chris Wood

Reputation: 53

I was following a tutorial on uwsgi and nginx and I kept having this same message and failure, but my problem was because the initial starting directory that I thought was set was not due to a no longer working config option, and my unix socket was being put (or attempted to put) in / directory. When I put the full path for my socket in the .ini config file it worked fine. yeeeargh that's a night I'll never get back :D

like this [uwsgi] .... socket = /var/www/stage/deeznts.sock

Upvotes: 0

Abhishek Tripathi
Abhishek Tripathi

Reputation: 1600

I also faced the same problem, it was because i didn't install php on my nginx server

By installing php-fpm this problem was totally solved. it is just the same thing as php fastcgi but with lots of configuration options and advantages

you can know more about php-fpm form here!

or You can follow this question!

Upvotes: 0

user2837768
user2837768

Reputation: 33

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

Upvotes: 2

cyberjar09
cyberjar09

Reputation: 770

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.

Upvotes: 2

Related Questions