Local Community

Access site on linux VM from host browser

I have setup on Local on a linux VM. It runs and I have created a site. I can access this site from the linux browser and the admin too.

All good so far. But I would like to access the site (and admin) from the host browser. I have switched off the firewall on the VM (I can set up rules when I get things working). Let’s say the site is called fred.local. And on the VM, I use http://fred.local in the browser.

But on the PC (but behind my router), I get the following results
http://vm-name/fred.local - an attractive 404 screen that mentions Local so is getting through.
http://vm-name - as above

Router mode is Site Domains, so Local router should be listening port 80.

Looking at the VM, I noticed that nginx is listening on this. I presume this is what the docs refer to as the “Local router”? Local router logs are empty.

So what am I doing wrong?


Hey @norricorp Welcome to the Local Community Forums!

I’ve never tried this sort of setup, but I think it might work!

Since Local’s router is listening on the default port 80 of the virtual machine – I think all you’d have to do is update the Hosts file on your host machine (the one running the VM) to point to the VM’s IP address for that domain.

Most virtualization software will allow you to get that IP address, and once you do, you can edit the hosts file with something like this to get it to work: fred.local

Note, I think you could extend this for any domain that Local is managing by adding additional domains to that host machine’s Hosts file: fred.local site2.local site3.local

Let us know if that works, or what you find!

Hi Ben,
I don’t think that is the solution. I have several VMs and normally I can access them from the network with http://vm-name:port. that is passed to the router which has the list so it does not need to go to external DNS.
The strange thing now is that whereas when I first tried this a few days ago, I was getting a 404 error from nginx (.config/Local/run/router/nginx/conf/local-router-error-pages/router-error-404.html) and now I get a connection timed out. This applies whether I use the vm-name or its IP address (it has its own IP address which shows in the router admin page)
As I mentioned the firewall is switched off on the VM. The only change since then is moving to an astra theme.
This may be a feature of Local. It is not a stopper but it is frustrating.

But that /fred.local part isn’t a port, it’s the domain name for the site that you want to access.

Editing the hosts file isn’t referencing an external DNS – it’s essentially pre-empting the need to make a request to DNS. Because it’s in the Hosts file, you’ll telling the computer “I know where I want this domain to go, don’t ask DNS for the answer.”

My guess for why that page was serving up a 404 is because Local’s router was trying to serve up a site called vm-name – but since that wasn’t a site that Local knows about, it couldn’t serve up that site.

Now that you’re getting a connection timed out message, something to check is if Local has started and at least one site has started so that the Router is listening on port 80.

Hi Ben,
so when I have connected to websites running on local VMs in the past, I have simply typed “vm-name:port” and as long as I have set up the VM firewall properly (or switched it off!) then up comes the website.
Now nginx in Local is listening on port 80. So by previous experience, typing to “vm-name” into the browser should work as the default is 80.
But does the addition of Local into the mix change things? For instance I have just noticed that if I use the browser on the VM and type “localhost”, I get the 404 screen from Local.
So it looks as though things are different with Local.
Anyway, I tried updating the PC hosts file with the VM-IP-address site_name.local and use site_name.local in the PC browser and connection timed out. Which makes sense.

I wonder if what is happening is that Local gets between nginx and the outside world. So when Local sees site.local, it can then pass that onto nginx. Hence localhost:80 will not work because Local is being bypassed and nginx is not getting the site.local. And there does not seem to be a way of of combining the VM IP address and the Local site name.

Still not to worry, it was a “nice to have” feature rather than an essential.

There is a post on this - Access the site in local network which does suggest what you suggest. I use VMware rather than VirtualBox and my VMs are always bridged so they have their own IP address from the router.