Yesterday, I tried running a Node.js server on port 80 on Ubuntu. I normally run Node.js server on ports > 3000.
First time when I tried running the server, I was expecting an error, because Apache2 was running on Ubuntu on port 80(default port for Apache2). I stopped Apache2 sudo service apache2 stop.
I tried running Node.js server again, and now it gave me EACCESS error. I was clueless about this.
When I tried to search for this error on Google, I found the answer on stackoverflow.com.
“Non-privileged user (not root) can’t open a listening socket on ports below 1024.” from stackoverflow
I then ran Node.js server using sudo node app. Bingo, it worked.
Also, when I was talking to my colleague Shiv (Guru-g Learning Labs), I learned that if applications run on port 80, then we can access them without the port number.
Eg: http://localhost/ instead of http://localhost:80. The latter option works too, it’s just that, we don’t have to explicitly specify the port numbers for port 80.
P.S: I haven’t tried running Node.js server on port 80 on Windows. Will document my results soon.
Categorised as: LearningItMyWay
Node.js EACCESS
1–2 minutes
Tagged as: Node.js





Leave a comment