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

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

upstream up_dev.example {

server {
    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;


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


3 Answers 3


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.


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.

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

try it

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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