Node.js Site is Refusing Connection

Your server is most likely not listening on [ipAddress]:8080 is likely only listening on localhost:8080. You can check this using netstat You will need to configure your server to listen on all/appropriate IP addresses. No doubt how to do this will be in the documentation.


I had the exact same issue with my ExpressJS app, and it's not your rerouting. I hacked at iptables and netstat for a long time until I realized that I had my HOST variable in my server.js file set to localhost. Here was my non-working code:

app.listen(PORT, 'localhost', function(err) {
    if (err) return console.log(err);
    console.log("Listening at http://localhost:%s", PORT);
});

Simply add a host variable

var HOST = 'actual_server_goes_here...';

And then do this:

app.listen(PORT, HOST, function(err) {
  if (err) return console.log(err);
  console.log("Listening at http://%s:%s", HOST, PORT);
});

Hope this helps :)

Tags:

Ubuntu

Node.Js