DEV Community

Médéric Burlet for Pixium Digital

Posted on

3 1

Listen on port 80 for node in linux

Node Permission Denied

Today I came across a node error when trying to run a simple express server on a amazon ec2.

Error: listen EACCES: permission denied 0.0.0.0:80

After some commands and research I realized that Linux architechture by default only lets ports lower than 1024 be listened by root.

This means that for running applications such as node which, should not be ran as root, we need to create a port redirect.

Using iptables to fix it

iptables is a user-space utility program that allows a system administrator to configure the tables provided by the Linux kernel firewall.

We will create a redirect of port 80 to 8080 in our scenario.

sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

To check if the route has been added successfully you can execute the following command:

sudo iptables --table nat --list

You should see something like this:

REDIRECT tcp -- anywhere anywhere tcp dpt:http redir ports 8080

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)