Node.js is not accessible from external IPs on Ubuntu

Solution 1:

Thanks for adding the last netstat output, it really helped. You can't access node.js from outside because it is listening on localhost IP i.e 127.0.0.1. You need to configure node.js to listen on 0.0.0.0 so it will be able to accept connections on all the IPs of your machine.

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");
console.log('Server running at http://0.0.0.0:8080/');

Solution 2:

According to your netstat output, port 8080 is open only for 127.0.0.1 which is localhost, hence accessing from the server works (which is localhost), but not from anywhere else.

The right output should look like

0.0.0.0:8080