Skip to content
Advertisement

How to start node.js on port 80 on a linux server?

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)

Advertisement

Answer

you can use ip tables to map port 80 to 8000

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8000

to make it permanent

sudo sh -c "iptables-save > /etc/iptables.rules"

and add

pre-up iptables-restore < /etc/iptables.rules

to your /etc/network/interfaces

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement