nginx/0.8.54 - 502 Bad Gateway

nginxn00b nginx-forum at
Wed Jul 20 13:43:14 UTC 2011


I'm running nginx as a reverse proxy for a jetty. I host a Liftweb App
on localhost:8080. Nginx is listening on Port 81.

Here is my nginx.conf:

server {
                listen 81;

                location / {
                        proxy_set_header  X-Real-IP  $remote_addr;
                        proxy_read_timeout 700;
                        proxy_set_header Host $http_host;
                        proxy_set_header X-Forwarded-For
When I try to point my browser to I always get a 502 Bad
Gateway message. I checked the log and found this:

connect() failed (111: Connection refused) while connecting to upstream,
client: 12.34.567.890, server:, request: "GET /favicon.ico
HTTP/1.1", upstream: "", host:

Does this means this port is blocked? I tried other but the result is
still the same...

My hosting company gave me the advice better not to use port 80 (i'm in
china) and use some socket instead. I don't know what they mean by that.
I use port 81 for nginx now. Anyone an idea what they could mean by "use
sockets"? I read somewhere that i can later forward all traffic from 81
to port 80.

Any hints a very much appreciated.

Posted at Nginx Forum:,212680,212680#msg-212680

More information about the nginx mailing list