Search code examples
apachesocketsubuntuvagrantvagrant-windows

localhost socket not connected error with vm


I downloaded vagrant and created a new ubuntu VM. Then I installed apache2 in ubuntu. When I accessed localhost:8080 from my web browser in windows it gave me this error "The webpage at http://localhost:8080/ might be temporarily down or it may have moved permanently to a new web address. ERR_SOCKET_NOT_CONNECTED"

I am doing my full stack nanodegree from udacity and they said that once apache2 is installed , i should be able to access localhost:8080 and get that apache intro page.

I am very new to all this so please tell me how to fix this.

My VAGRANT FILE:

    Vagrant.configure("2") do |config|
      config.vm.box = "ubuntu/trusty64"
      config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: 
      "127.0.0.1"
      end

Solution

  • Just remove host_ip, if you're using it with 127.0.0.1 you will need to specifically add the guest_ip of the VM too.

    Anyway you provide this information when you're running multiple VM and wants to forward on the same port on the host (80 in your example), if its not your case, just remote the host_ip parameter.

    so all following will work

    • if you're running a single VM, the easy solution

      config.vm.network "forwarded_port", guest: 80, host: 8080
      
    • if you're running multiple VM and want to forward on the same host port

      config.vm.network :forwarded_port, :host => 8080, :guest => 8080, :host_ip => '<VM_IP_bound_to_VM>'
      

    or

        config.vm.network :forwarded_port, :host => 8080, :guest => 8080, :guest_ip => '<IP_GUEST_VM>' :host_ip => '127.0.0.1'