How can I get Node.js to listen on port 80?

Hi! I followed the instructions here,, and I got a Node app up and running on port 3000. When I direct requests to that port, I see my app, but not when I send a request without specifying a port.

I tried running $ PORT=80 node app, and Node threw an error and quit. It worked when I used PORT=8080 though.

On IRC, @kamal_ suggested I install and configure NGINX to to serve the static files “and pass everything else to Node.js”, and now I have NGINX up and running. When I go to my droplet’s IP now, I see “Welcome to nginx!” instead of having the connection refused, but I still have to append :3000 to the URL to see my Node app.

This is the NGINX config file I got from @kamal_:

What are the next steps to making the app load on requests to the default port?

Thanks in advance!

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

For people looking for a quick and easy solution, not the most robust, but it will get you running, try: <br> <br>redirect port 80 to port 3000 with this command: <br> <br> sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000 <br> <br>Then launch Node.js on port 3000. Requests to port 80 will get mapped to port 3000. <br> <br>You should also edit your /etc/rc.d/rc.local file and add that line minus the sudo. That will add the redirect when the machine boots up. <br> <br>found this (here)[] Hope this helps someone.

You can use the proxy

    access_log /var/log/nginx/your.log;
    location / {

Launching the app with sudo works fine. There’s probably security implications. I’m not a backend guy. But it will work for now.

Edit: No, it’s not… I give up.