Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Instead of seeing the rhodecode page when visiting repo.xxx.com I get a 502 (Bad Gateway).

Here is the nginx error.log entry.

2013/03/14 21:48:33 [error] 11207#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 11.111.111.11, server: repo.xxx.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "repo.xxx.com"

Here is the relevant portion of my nginx.conf.

upstream rhodecode{
        server 0.0.0.0:5000;
}

server {
        listen 80 default;
        server_name www.xxx.com;

        location / {
                root /opt/html;
                index index.html;
        }
}

server {
        listen 80;
        server_name repo.xxx.com;

        proxy_redirect              off;
        proxy_set_header            Host $host;
        proxy_set_header            X-Url-Scheme $scheme;
        proxy_set_header            X-Host $http_host;
        proxy_set_header            X-Real-IP $remote_addr;
        proxy_set_header            X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header            Proxy-host $proxy_host;
        client_max_body_size        400m;
        client_body_buffer_size     128k;
        proxy_buffering             off;
        proxy_connect_timeout       7200;
        proxy_send_timeout          7200;
        proxy_read_timeout          7200;
        proxy_buffers               8 32k;

        location / {
                try_files $uri @rhodecode;
        }

        location @rhodecode {
                proxy_pass http://rhodecode;
        }

}

I also changed the host property in my rhodecode ini file to be host=0.0.0.0. This is all being done on a ubuntu 12.04 LTS server hosted by linode (if that matters).

Most of what I've been reading would suggest that it is a "permissions" issue with ports not being opened up correctly or somehow my loopback interfaces aren't configured correctly.

Here is the output of iptables -L -n.

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
share|improve this question

2 Answers 2

The problem is here:

upstream rhodecode{
        server 0.0.0.0:5000;
}

You didn't specify a valid address for nginx to connect to; 0.0.0.0 is not a valid destination IP address.

To resolve the issue, specify the actual IP address, such as 127.0.0.1.

share|improve this answer
    
I've also tried it with 127.0.0.1, same problems, however I will change it back. –  John Mar 14 '13 at 23:01

As it turns out I am an enormous tool who can't follow tutorials.

I didn't have rhodecode setup properly, I didn't run paster setup-rhodecode production.ini, where production.ini is the config file for rhodecode.

So the lesson here is if you get a connection refused error, a 502 display page, and you run netstat and you don't see the port you're looking for (5000 in my case) then your app is probably crashing and you should probably check your app's error log instead of blaming ubuntu's permission scheme.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.