I have installed the node js on Ec2 successfully and my website and domain are running fine but when I try to run node js it won't run.
I have follow the some tutorial and I have done the following step on my aws.
1. I have added a port 9000 on my security group
2. I have done the pre-routing on iptables using below command
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 9000
But after running above code my domain stop running means when I try to open my site mydomain.com it shows nothing and If I remove the that rule than again its working.
I have also tried the below solution to running node as root level to listen port on 80.
sudo node server.js
but after that I am getting below error
Error: listen EADDRINUSE :::80
at Object.exports._errnoException (util.js:949:11)
at exports._exceptionWithHostPort (util.js:972:20)
at Server._listen2 (net.js:1253:14)
at listen (net.js:1289:10)
at Server.listen (net.js:1385:5)
at Object.<anonymous> (/home/mcook/domains/development.mcook.co.in/public_html/server.js:36:5)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
I just want to make my node and my site both must running and for that which command and port I need to run.