Score:0

Accessing a web application running in Ubuntu from other machines in the same network

gb flag

I have an application running in Ubuntu 22 that deploys a web server at port 8000 and it's accessible through the browser at http://127.0.0.1:8000/ (from the same machine). I would like to access this URL from other machines in the network so I tried using the IP address http://192.168.1.21:8000 (rather than the localhost one; 127.0.0.1) and I checked the port 8000 is opened in the firewall... But so far, I can't access this website from outside the Ubuntu machine... I'm wondering if I need something else to configure in Ubuntu to make this work. In windows, you can access any webserver running at localhost using the machine's IP address (assuming the port is opened in the firewall), but it seems this is not the case in Ubuntu? Note that I don't have a webserver such as Apache installed and running, but the application itself deploys a webserver so I assume this is not needed.

Thanks in advance Gus

Score:1
br flag

The Linux operating system is similar to Windows in terms of network services. A running service and an open port on the firewall should be enough.

But beware. An application can only have a port open for local access. You will find this by making sure that the listening address of the network service is not 0.0.0.0, but only 127.0.0.1.

Use the netstat command and pay attention to the third column. The full command with parameters is below.

The following case shows two services, one of which listens only locally (TCP port 5939) and the other is accessible over the network from other addresses (TCP port 10000).

tcp        0      0 127.0.0.1:5939          0.0.0.0:*               LISTENING  2638/teamviewerd    
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTENING  2797/perl           

I assume your web server has an IP address 192.168.1.21. Please attach here the system response to the following commands:

Server

sudo netstat -lntp

sudo iptables-save | grep -C 3 8000

Another PC in the same network (OS Linux)

ping -c 3 192.168.1.21

nc -4zv 192.168.1.21 8000

The netcat (nc) can be installed by:

sudo apt update
sudo apt install netcat-openbsd
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.