Can't connect to a running server in vagrant with windows OS

104 Views Asked by At

I recently installed vagrant in windows 10 and everything just work fine but as I know almost nothing about Virtualization or VM's I got a problem when connecting to a server.

I have a nodejs server running in a vagrant box and of course a address or "local host" but can't connect to it through my main OS, just the typical "Problem Loading Page" or can’t establish a connection to the server at localhost:8000.

I'm using ssh instead of winssh, idk if it's useful.

I assume is a problem with the localhost, which of course are different between vagrant and windows.

The docs didn't where helpful.

1

There are 1 best solutions below

0
MacTruck3Code On

Because it seems like you may be new to Vagrant the quickest and easiest way for you to access your VM via localhost is to set up port forwarding in your Vagrantfile.

Vagrant.configure("2") do |config|
  config.vm.network "forwarded_port", guest: 80, host: 8080
end

Using the example above you’ve forwarded your host port, 8080, to your vm’s port 80. So when you go to localhost:8080 it will return whatever is listening on port 80 of your VM. Just make sure that if you have a firewall setup in your VM you open port 80.