When I try to start node on port 80, the error tells me that the port is in use. I imagine that's Apache.
What is the proper way to "take over" port 80, and keep it that way after a server restart?
(Linux xxxx.__.com 2.6.32-5-amd64 #1 SMP Tue Jun 14 09:42:28 UTC 2011 x86_64 GNU/Linux)
To take over port 80 when another process is listening on it, you must kill the process (or somehow tell it to stop listening). To ensure that Apache doesn't try to listen on port 80 again the next time it starts, you need to edit its configuration or prevent it from starting up.
To see which process is listening on port 80, run
sudo netstat -ntap
and look for the row withLocal Address
ending in port:80
. The PID of the process (and the name) is in the far right column.you can use ip tables to map port 80 to 8000
to make it permanent
and add
to your /etc/network/interfaces
A constantly running unused apache maybe a security hole, in any case no sense in running unused services.
On the chance you're on ubuntu, this what I used..
You can access port 80 once you stop the service currently using it.
In your case, follow these steps:
1) Use
systemctl
to stop apache2:2) Check apache2 status:
Or just by entering
http://localhost
in your browser. If you get an error, you are good to go.3) Now start your NodeJS server on port 80.
4) You can access your server at
http://localhost
UPDATE
If you are seeing errors on your console, try
node
preceding withsudo
For eg.sudo node server.js
Here are the errors
you can use node.js with node-http-proxy check this link How to use vhosts alongside node-http-proxy? and How do I run Node.js on port 80?
Thanks & Regards,
Alok