Member-only story

How to Run Your Node Application using Reserved Port

Tek Loon
2 min readMay 15, 2020

--

Firstly, what is reserved port? Reserved port is a set of port numbers ranging from 0 to 1023 which is reserved for privileges services, such as port 80 for HTTP, 443 for HTTPS, 22 for SSH and etc.

Problem Statement

When you’re trying to start your Node project using a reserved port in Linux, you will most likely see this error.

ERR 0.0.0.0:443 Permission denied

This is because ONLY root can run an application using a reserved port in Linux.

Unfortunately, I don’t have root user access and this is a pretty normal situation where developers would not be given root access to the server.

Desired Output

What I actually want to achieve here?

  • Able to run Node Application using port 443

Luckily, I found a pretty good solution for my use case which is using setcap

Solution

setcap is a Linux command and it basically allows me to add the capability of non-root port binding to binary. It simply means even though I am not a root user, I can run my project using a reserved port.

However, since this capability is added to binary. Which in my use case, I am running a…

--

--

Tek Loon
Tek Loon

Written by Tek Loon

Coder and Writer. If you enjoy my stories— support me by https://www.buymeacoffee.com/tekloon so I can keep writing articles for the community.

No responses yet