I am trying to run a nodeJS server on an Amazon EC2 instance but I cannot access it in public.
I have read several SO questions about this and also some blogs posts but no solution works for me. This is my server config:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Simple server\n');
}).listen(4444);
console.log('Server running');
This is the output of iptables -l:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:4444
ACCEPT tcp -- anywhere anywhere tcp spt:4444
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp spt:4444
And the port 4444 is also added on the instance's security group.
After the server has started, running curl localhost:4444 echoes the expected "Simple Server".
But I am not able to connect to the public DNS / IP address.
Do you know which setting is still missing?