How can I view a localhost:"port" web browser page from host system inside a Virtual Machine?

In order to use a specific application, I need use a web browser to view a localhost:“port” page so I can utilize the application, however, I do not want to have a web browser inside my host system, so I use a Virtual Machine when I need to use a web browser.

But for some reason, inside the guest system, I can’t access the localhost:“port” page, even though everything is being done on the same physical machine, thus in theory the localhost page should be inside it. I tried searching online for information, but couldn’t find anything about my issue. I also cannot run the application in question inside the VM, since it requires a dedicated Graphics Card to work, and GPU pass-through is not an option in my case.

Virtualization tested with Virt Manager (both system and user connection), Web browser tested with Firefox (Flatpak install) and Epiphany (DNF and Flatpak installs).

Unsure if this matters in any way, but ufw package is also installed on both host and guest systems, and enabled on system startup, but without any additional configurations.

localhost means the machine you are using it, whether it is real or virtual hardware, so inside the VM, it means VM and localhost:port means look for a program which runs on the VM and listens on that port. Inside the VM, the IP address of your host is the gateway of the VM. For example, let’s say your VM’s IP address is 192.168.X.Y and its gateway is 192.168.X.1, you can reach the application running on your host with 192.168.X.1:port.


You should also allow incoming connections for your host on that port.

1 Like

Technically, they’re not the same logical machine, the guest machine’s “localhost” is different than the host’s “localhost”. A browser running in a guest machine should be able to access the host by its proper name or IP address, but firewall / listen rules would have to allow for it. From the host’s perspective, the guest is mostly seen as just another machine on your network.

Depending on what you’re wanting to accomplish by running the browser inside a virtual machine, you may be able to use the Flatpak version or alternatively a toolbox instead both of which are a bit lighter than a virtual machine and a bit easier to manage.


Assuming the default network and firewall configuration for libvirt:

# Host
sudo firewall-cmd --permanent --zone=libvirt --add-port=8080/tcp
sudo firewall-cmd --permanent --zone=libvirt --add-port=8443/tcp
sudo firewall-cmd --reload

# Guest
curl http://_gateway:8080/
curl https://_gateway:8443/

I’m not sure if I am doing something incorrectly, but I’ve tried the following methods mentioned for the VM approach, but wasn’t success (The last one mentioned was the only one to give me an error message, about refusing to connect when trying to use curl for both 8080 and 8443).

1 Like

I never heard of toolbox before. Installing the flatpak version of Firefox inside it actually works, as I can view the localhost port, yet other applications can’t use Firefox to open links (which in my case is actually preferred), instead it opens my text editor application the same way it would without any web browser installed.

This might even be better than what I was previously trying to achieve, but since I just learned about toolbox recently, I’ve got some questions about it, and I haven’t got enough time to research more about it, so would you mind if I ask some questions about it?

1: From my first impression, it seems applications inside toolbox can’t be launched by the main system, but it doesn’t prevent the toolbox application from accessing the files outside of toolbox?

2: Where are the files from toolbox saved? I found where the Firefox flatpak (in my case installed with user) was, but I am not sure about everything else.

Both Flatpaks and toolboxes are container / image centric tools, while “containerized” they’re just regular applications (processes) running on your machine with some restrictions. The Flatpak version of Firefox should act very similar to the RPM version including the ability to open links if it’s designated as the default application for that type of file.

I truly don’t know what you’re trying to accomplish based on what you’ve asked so far, but I do want to be very clear on one point. A virtual machine generally does not have access to your files unless specifically granted, both a Flatpak and toolbox will have access to some if not all of your files no different than an RPM installation.

It is something you will definitely need to spend a bit of time to research if you want to understand them better, but to answer the specific questions:

#1 - Toolboxes, generally, have access to most of your home directory files. You can use the toolbox run command to run specific commands inside of a toolbox (container).

#2 - Flatpak user data is under $HOME/.var/app and container storage by default would be in $HOME/.local/share/containers

Let’s check your network and firewall configuration on the host:

sudo dnf -y install libvirt-client
sudo virsh net-list --all
sudo virsh list --all; virsh list --all
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --info-zone=libvirt
sudo ss -lnpAinet | grep -e :PORT_NUMBER