Search code examples
httpportforwardingvagrant

browser in host can not see vagrant box, portforward does not work


I have installed Vagrant in my Window XP, and in my Vagrantfile I have:

Vagrant::Config.run do |config|
  # Setup the box
  config.vm.box = "lucid32"
  config.vm.forward_port 80, 8080
  config.vm.network :hostonly, "192.168.10.200"
end

But I see no sign of my vagrant box when I type "http://192.168.10.200:8080" in browser.

IP address of the virtual box is correct, because from within the vbox, I have:

vagrant@lucid32:~$ ifconfig
....
eth1      Link encap:Ethernet  HWaddr 08:00:27:79:c5:4b
          inet addr:192.168.10.200  Bcast:192.168.10.255  Mask:255.255.255.0

There seem to be no firewall problem because if I type

vagrant@lucid32:~$ curl 'http://google.com'

it works fine.

I have read Vagrant's port forwarding not working and tried:

vagrant@lucid32:~$ curl 'http://localhost:80'
curl: (7) couldn't connect to host

and also

vagrant@lucid32:~$ curl 'http://localhost:8080'
curl: (7) couldn't connect to host

So, looks like port forward is not working...

If you know what I can do so I can access my vbox from host browser, can you help me?

Thanks in advance


Solution

  • If you just started a Vagrant box with this Vagrantfile, there is nothing more than an empty Ubuntu Lucid, which does not run any service yet. So there is nothing served on port 80, this is why there is nothing to see either from inside the box on port 80 or the host machine on 8080.

    For you Vagrant machine to provide some services (such as a web server on port 80), you have to do some provisioning. You can do it manually or using Chef or Puppet which are hooked into Vagrant's up process.