Access node based web server with public IP

July 22, 2017 7.1k views
Ubuntu Node.js

I have installed a node based lightweight web server in my droplet and trying to serve a directory with it.

mkdir web
cd web

This shows the output as -

Starting up http-server, serving ./
Available on:

But when I try to access from my browser, it times out. However, logging in to another terminal via ssh and running curl gets the output.

Could anyone please indicate what I need to do to access the server from outside the network?

3 Answers

Hi @jaibatrik

Can you check if your firewall is active?

sudo ufw status

And run this command to show listening services:

sudo lsof -iTCP -sTCP:LISTEN -P
  • On running sudo ufw status, I get the following -

    Status: active
    To                         Action      From
    --                         ------      ----
    22                         LIMIT       Anywhere                  
    80                         ALLOW       Anywhere                  
    443                        ALLOW       Anywhere                  
    22 (v6)                    LIMIT       Anywhere (v6)             
    80 (v6)                    ALLOW       Anywhere (v6)             
    443 (v6)                   ALLOW       Anywhere (v6)  

    I see that 8080 is not listed here. Running sudo lsof -iTCP -sTCP:LISTEN -P gives the following -

    sshd    1875      root    3u  IPv4  18383      0t0  TCP *:22 (LISTEN)
    sshd    1875      root    4u  IPv6  18392      0t0  TCP *:22 (LISTEN)
    node    2536 jaibatrik   12u  IPv4  22839      0t0  TCP *:8080 (LISTEN)

    Here, I can see an entry for node.

I use vpn service to protect my online privacy. In my life I often use VPN, especially during trip to different countries, where some sites were blocked. But sometimes vpn can work bad. In this case I use one service tool what is my ip which can help to know the vpn efficient .

Have another answer? Share your knowledge.