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.

Posted at Nginx Forum:

On 3 December 2012 20:08, Gallitin [email protected] wrote:

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

The error message of “Connection refused” would seem to be pretty
self-explanatory … :slight_smile:
What about it is surprising you?

J

Jonathan M. // Oxford, London, UK
http://www.jpluscplusm.com/contact.html

I didn’t understand why it’s refused? Where can I see why it was
refused?

Posted at Nginx Forum:

On Mon, Dec 03, 2012 at 03:08:09PM -0500, Gallitin wrote:

Hi there,

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

Can your nginx access the server you have configured it to?

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

What do you get when you do

curl -i http://108.166.94.94:7080/assets/js/msgFBmodal.js

from the nginx server? (That’s not exactly the same as nginx would do,
but the error message should be instructive.)

f

Francis D. [email protected]

On Mon, Dec 03, 2012 at 03:29:19PM -0500, Gallitin wrote:

Hi there,

Via SSH? Yes I can do this.

Yes, so long as you are running curl on the same machine that nginx is
running on, it should be a valid network test.

When I do that it says

HTTP/1.1 404 Not Found

Apache Server at 108.166.94.94 Port 7080

Ok, that suggests that there is a listener on the host:port that nginx
is trying to access. If you add "-H Host:demo.domain.com " to the curl
command (just after "-i "), you will more closely mimic what nginx
should
be doing – that might show you the correct content.

No if I do:
curl -i http://domain.com/assets/js/msgFBmodal.js

It returns the page code from that file.

I’m unsure what you mean here.

If it is “now it is all working”, then that’s good and the most likely
reason for the problem was that apache was not running, or was
firewalled,
when you first tested and that has now been fixed.

If it is “here is a similar thing that is working, but my test case is
not”, then can you provide enough of the nginx.conf to allow the test
be reproduced? Probably, that will be just the location{} block that has
the proxy_pass that is used in the request, plus the relevant upstream{}
definition if there is one, plus whatever config is in that server{}
but outside all location{}s.

(Or just include the whole nginx config.)

Cheers,

f

Francis D. [email protected]

Sorry for the grammar error.

If I do curl -i http://domain.com/assets/js/msgFBmodal.js
it returns the code from the msgFBmodal.js page. Yet if I hit the page
via
browser I still receive the gateway error.

The nginx.conf file is:

#user nginx;
worker_processes 1;

#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] 

“$request”

# '$status $body_bytes_sent “$http_referer” ’
# ‘“$http_user_agent” “$http_x_forwarded_for”’;
“nginx.conf” 40L, 847C

Posted at Nginx Forum:

On Tuesday 04 December 2012 01:32:04 Gallitin wrote:

Sorry for the grammar error.

If I do curl -i http://domain.com/assets/js/msgFBmodal.js
it returns the code from the msgFBmodal.js page. Yet if I hit the page via
browser I still receive the gateway error.
[…]

You should clear your browser’s cache.

wbr, Valentin V. Bartenev

http://nginx.org/en/donation.html

Just tried that still receiving the error

Posted at Nginx Forum:

Via SSH? Yes I can do this.

When I do that it says

HTTP/1.1 404 Not Found
Date: Mon, 03 Dec 2012 20:28:35 GMT
Server: Apache
Content-Length: 286
Connection: close
Content-Type: text/html; charset=iso-8859-1

404 Not Found

Not Found

The requested URL /assets/js/msgFBmodal.js was not found on this server.


Apache Server at 108.166.94.94 Port 7080

No if I do:
curl -i http://domain.com/assets/js/msgFBmodal.js

It returns the page code from that file.

Posted at Nginx Forum:

I run the curl command via SSH and I receive the code output from that
file.

I browse to the page that uses that file and receive the gateway error.

Posted at Nginx Forum:

On 3 December 2012 21:56, Gallitin [email protected] wrote:

Just tried that still receiving the error

So a curl runningonyourdesktop* receives a 200 as expected, but
your browser onyourdesktop does not?

Jonathan

On 3 December 2012 22:03, Gallitin [email protected] wrote:

I run the curl command via SSH and I receive the code output from that
file.

I browse to the page that uses that file and receive the gateway error.

You need to show us some commands running, some output, and nginx
config - without redacted network names. This is too
annoying/confusing to help you troubleshoot without seeing exactly
what you’re running exactly where.

Jonathan

Gallitin wrote in post #1087697:

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.

Posted at Nginx Forum:
connect() failed (111: Connection refused) while connecting to upstream

Did you got solution to the problem ? I’m getting error
connect() failed (111: Connection refused) while connecting to upstream

You check more details upon opening site http://www.dealslama.com

An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.

If you are the system administrator of this resource then you should
check the error log for details.

Faithfully yours, nginx.

On Mon, Dec 03, 2012 at 04:32:04PM -0500, Gallitin wrote:

Hi there,

Sorry for the grammar error.

No worries. Once it is clear what works and what fails, we can see what
to do next.

If I do curl -i http://domain.com/assets/js/msgFBmodal.js
it returns the code from the msgFBmodal.js page. Yet if I hit the page via
browser I still receive the gateway error.

So, include all details each time, even if it looks repetitive.

Yes or no: “domain.com” is your nginx-hosted web site, and resolves to
your nginx server?

From a shell on the nginx server, what does

curl -i http://domain.com/assets/js/msgFBmodal.js

return? HTTP 200 and the content of the msgFBmodal.js file, or something
else?

From a shell on your PC, the same machine your browser runs from, what
does

curl -i http://domain.com/assets/js/msgFBmodal.js

return? HTTP 200 and the content of the msgFBmodal.js file, or something
else?

From your browser, what do you see when you try to access

http://domain.com/assets/js/msgFBmodal.js

? The content of the msgFBmodal.js file, or something else?

The nginx.conf file is:

#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

“nginx.conf” 40L, 847C

Unfortunately, that doesn’t show the configuration. It only shows the
top
half of the main file; I suspect it will “include” some other files.
What
matters is the configuration of the server{} block that handles
domain.com.

f

Francis D. [email protected]

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

My site : http://www.dealslama.com showing below error message.

An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.

If you are the system administrator of this resource then you should
check the error log for details.

Faithfully yours, nginx.

Well, due to occurring such problems of not getting the confirmation. you may use such services as SMPP Server, SMPP.