Access node based web server with public IP

Posted July 22, 2017 93.6k views

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?

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
2 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.