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: http://forum.nginx.org/read.php?2,233519,233519#msg-233519
on 2012-12-03 21:08
on 2012-12-03 21:19
On 3 December 2012 20:08, Gallitin <nginx-forum@nginx.us> 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 ... :-) What about it is surprising you? J -- Jonathan Matthews // Oxford, London, UK http://www.jpluscplusm.com/contact.html
on 2012-12-03 21:21
I didn't understand why it's refused? Where can I see why it was refused? Posted at Nginx Forum: http://forum.nginx.org/read.php?2,233519,233522#msg-233522
on 2012-12-03 21:22
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 Daly francis@daoine.org
on 2012-12-03 21:29
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 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /assets/js/msgFBmodal.js was not found on this server.</p> <hr> <address>Apache Server at 108.166.94.94 Port 7080</address> </body></html> 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: http://forum.nginx.org/read.php?2,233519,233524#msg-233524
on 2012-12-03 21:45
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 <snip> > <address>Apache Server at 108.166.94.94 Port 7080</address> <snip> 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 Daly francis@daoine.org
on 2012-12-03 22:32
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: http://forum.nginx.org/read.php?2,233519,233527#msg-233527
on 2012-12-03 22:54
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.com/support.html http://nginx.org/en/donation.html
on 2012-12-03 22:57
Just tried that still receiving the error Posted at Nginx Forum: http://forum.nginx.org/read.php?2,233519,233530#msg-233530
on 2012-12-03 23:00
On 3 December 2012 21:56, Gallitin <nginx-forum@nginx.us> wrote:
> Just tried that still receiving the error
So a curl *running*on*your*desktop* receives a 200 as expected, but
your browser *on*your*desktop* does not?
Jonathan
on 2012-12-03 23:03
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: http://forum.nginx.org/read.php?2,233519,233532#msg-233532
on 2012-12-03 23:20
On 3 December 2012 22:03, Gallitin <nginx-forum@nginx.us> 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
on 2012-12-04 00:58
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: <snip> > # '$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 Daly francis@daoine.org
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.