Phil Anderson
Phil Anderson

Reputation: 46

NodeJS http server on Ubuntu 15.10 Server : New Install : ERR_CONNECTION_REFUSED externally

I have successfully installed nodejs on a Ubuntu 15.10 Server.

It's running fine INTERNALLY so curl http://localhost:8080 is returning my

Hello World

successfully.

Externally though I am getting ERR_CONNECTION_REFUSED.

I've done a lot of research and can't find the fix which works for me.

  1. UFW ==> disabled

  2. NMAP ==> PORT 8081 IS CLOSED

  3. NETSTAT -tulpn seems to indicate server is indeed listening on correct port.

I am puzzled as to why 8081 traffic is being refused unless my cloud provider has blocked this port - how would I determine if it's my Ubuntu or the cloud provider which is blocking this port? NMAP is definitely saying 8081 is closed but I am not sure what to do next.

Node code is just the most basic http web server possible

        var http = require('http');

        http.createServer(function (req, res) {
            res.writeHead(200, {'Content-Type': 'text/plain'});
            res.end('Hello World\n');
        }).listen(8080, "0.0.0.0");

Upvotes: 1

Views: 224

Answers (1)

Maeve Kennedy
Maeve Kennedy

Reputation: 249

I would suggest working with your cloud provider as you likely need to work with their firewall or endpoint settings. Everything else you are doing should be fine if in fact your firewall is completely off.

Interestingly enough, the fact that you can shut off your firewall is an important lesson in the external management of endpoints of cloud providers.

With Azure for instance you need to specify an endpoint:

Azure endpoints dialog

Upvotes: 1

Related Questions