Cannot access local server with IP address while localhost and 127.0.0.1 can

I am trying to let other computers to access my local server but I tried myself locally that I cannot access it locally even myself.

Several things you should know:

My target

Visit my server via http://172.26.141.106:5201/

What I can do now

I can access my server via these two ways:

  • http://localhost:5201
  • http://127.0.0.1:5201

IP configuration

Result of ifconfig | grep inet

      inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
      inet addr:172.26.141.106  Bcast:172.26.141.255  Mask:255.255.255.0
      inet6 addr: fe80::f767:cd56:9641:d3a9/64 Scope:Link
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host

Hosts

Output of cat /etc/hosts:

127.0.0.1   localhost.localdomain localhost
127.0.0.1   hearen.pc
127.0.0.1   hearen-OptiPlex-7050
127.0.0.1   staging
127.0.0.1   arthas
172.26.141.106  localhost hearen.pc

Firewall

$ sudo ufw disable
Firewall stopped and disabled on system startup
$ sudo ufw status
Status: inactive

Is there some way that I missed out? All I want is to let others access my server via http://172.26.141.106:5201/

Any help will be appreciated :)

Updated 2019-01-10

With the help of @Ed King, I check the ports via sudo lsof -i -P -n | grep LISTEN | grep 5201 and only 127.0.0.1 was listenned on.

Problem solved after I configured my Angular server to listen on 0.0.0.0 .


Check that your server is listening:

sudo lsof -n | grep TCP | grep LISTEN

You can also check the route using nc. Start nc on the server listening on an unused port and then connect from another machine -- this will verify iptables and routes are correct.

My guess is that you're listening on the localhost only.


I fixed this issue with following ways:

  1. I run the command

    sudo ufw status 
    

    And I found that the port 80 (in my case) was not in the list.

  2. Then I run the command

    sudo ufw allow 80
    

    This fixed the issue.