How to access Node.JS project locally?

Posted September 7, 2020 563 views
Node.jsJavaScriptUbuntu 18.04

I have a node.js project running on the ubuntu server.—> App is listening on 5000.

So, I want to access it locally. Like http://server_ip:5000

How can I do this?

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.

Submit an Answer
1 answer

I have no idea how to access node.js app locally using console and being satisfied of what you get, at the same time.
It is your decision if your node.js is front-end or back-end environment. You can access it from outside when you configure it as front-end environment. That means, your app must listen on your droplet’s public IP. You can check what ip addresses your app listens on.

sudo netstat -tulpn

If you get one out of the lines below, your app can be reachable from the Internet.

Proto       Local Address                  State         
tcp         0                 LISTEN
tcp         your_droplet_public_ip:5000    LISTEN        

In addition, if you have any firewall installed, you need to configure it to allow connections on specific port (TCP 5000, in your case).