linux - cannot run node.js webservice on port 80 or 443 -


i have vps running centos , i'm experimenting node.js. ran example node.js server running correctly on various ports, whenever tried run node on port 80 (same error 443) following error:

root@mic [~/projects/nodetutorial2]# node index.js server running on port 80.  events.js:72         throw er; // unhandled 'error' event               ^ error: listen eaddrinuse     @ errnoexception (net.js:883:11)     @ server._listen2 (net.js:1021:14)     @ listen (net.js:1043:10)     @ server.listen (net.js:1109:5)     @ object.<anonymous> (/root/projects/nodetutorial2/index.js:8:4)     @ module._compile (module.js:456:26)     @ object.module._extensions..js (module.js:474:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:312:12)     @ function.module.runmain (module.js:497:10) 

i've tried redirect port 80 3000 doing:

sudo iptables -t nat -a prerouting -i eth0 -p tcp --dport 80 -j redirect --to-port 3000 

apparently executed command twice because: when did a: sudo iptables -t nat -l, returned:

root@mic [~]# sudo iptables -t nat -l chain prerouting (policy accept) target     prot opt source               destination redirect   tcp  --  anywhere             anywhere            tcp dpt:http redir ports 3000 redirect   tcp  --  anywhere             anywhere            tcp dpt:http redir ports 3000  chain postrouting (policy accept) target     prot opt source               destination  chain output (policy accept) target     prot opt source               destination 

but no avail, still same error.

i tried see running on port 80 netstat -tulpn | grep:80 command , returns:

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   listen      477/httpd tcp        0      0 :::80                       :::*                        listen      477/httpd 

so had killed process running on port 80 , got kicked off vps immediately.

what ports should running node.js webservice?

according putty settings port i'm accessing port 22, don't understand going on there. additionally, i'm not planning run webservice root. i've created user less permissions run node.js webservice.

  1. setup nodejs use port 8000
  2. install nginx , set reverse proxy nodejs app.

don't use apache, creates thread/process every request, while nginx doesn't. works similar nodejs event loop have queue of request need processed , nginx worker processes take each request queue , process - in case send request nodejs server , wait response.

and never use nodejs on port 80, there many use-cases handle , there no need reinvent wheel


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -