I started pm2 server on my server running ubuntu 20.
To simplify the problem, I created a hello world app using node, like this (/var/www/html/pip/exampleserver.js):
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(3000, '0.0.0.0');
console.log('Server running at http://0.0.0.0:3000/');
After starting the server with 'pm2 start exampleserver.js', the server is started, and it works fine when I access it from localhost :
wget -qO- localhost:3000
Result : "Hello World"
But I get ERR_CONNECTION_REFUSED when accessing the page from another computer on the same network (from http://10.200.96.23:3000, either from browser or command line)
However, when I change the script to listen to port 80 and restart pm2, it works just fine from the other computer (from http://10.200.96.23). It shows the result "Hello World".
Here is the result of netstat and ufw status that i've disabled in advance : netstat and ufw status
Screenshot of error connection refused : ERR_CONNECTION_REFUSED
I tried other ports, but nothing works other than 80. I don't want to run this server on port 80. What could be the problem?
3000
is not open for the outside world that's why you are getting this error - aRvi