3

I'm trying to setup NGINX as the frontend of my NodeJS app, which is live on 127.0.0.1:3000, but i can't resolve this 502 error. NGINX is locally reachable at http://55.55.55.5/ or http://dev.example

dev.example (file in: /etc/nginx/sites-available and symlinked to sites-enabled)

upstream up_dev.example {
    server 127.0.0.1:3000;
}

server {
    listen 0.0.0.0:80;
    server_name dev.example example;
    access_log /var/log/nginx/dev.example.log;

    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://up_dev.example/;
      proxy_redirect off;
    }
 }

error.log

2014/09/17 19:38:26 [error] 1679#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 55.55.55.1, server: , request: "GET / HTTP/1.1", upstream:$

1

3 Answers 3

11

It could also be SELinux that's preventing the connection being made as httpd_can_network_connect is off by default.

getsebool httpd_can_network_connect

Check if this is turned on. If not, turn it on by running

setsebool -P httpd_can_network_connect on

The -P means persistent changes so the new boolean will still be in effect even after a reboot.

3

Connection refused means that no software is listening to port 3000 on your server. You should check that Node.JS is running properly and that it is listening to port 3000.

0
- proxy_pass http://up_dev.example/
+ proxy_pass http://up_dev.example

try it

1
  • Not even close.
    – womble
    Aug 15, 2017 at 2:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .