Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vagrant cannot connect to virtual box

When I vagrant up with a basic Vagrantfile with only those 2 lines configured :

config.vm.box = "ubuntu/trusty32"
config.vm.network "forwarded_port", guest: 80, host: 8080

I see my virtual box opening, but then my vagrant log shows this line multiple times until timeout :

default: Warning: Connection timeout. Retrying...

Then, some time after the timeout, the virtual box box is finally asking me for a login, but that was too long!

So I log with vagrant/vagrant. Then on my physical machine, if I "vagrant ssh". Nothing happens, until this :

ssh_exchange_identification: read: Connection reset by peer

What's wrong ? Any idea ?

(btw my port 8080 is free, and I also tried vb.gui = true,

and it's working with box hashicorp/precise32)

like image 203
trogne Avatar asked Jul 21 '15 15:07

trogne


1 Answers

If you have a computer that supports hardware vir­tu­al­iza­tion, you need to enable it in the BIOS.

If you do not have a modern computer with a CPU that supports hardware vir­tu­alisa­tion, like in your case, you will have to stick to 32 bits boxes. That box, trusty32, is 32 bits so it should work.

But if it does not, you can try any of the things Piotr Banaszkiewicz describes in his blog post here. The post is a little bit old (2012) but we are talking about an even older CPU here (2009), so it may still apply.

As a summary, quoting here:

  • In the VirtualBox GUI select VM → Settings → System → Ac­cel­er­a­tion, then uncheck everything.
  • Go to the directory containing your VirtualBox VMs, then to your VM’s directory, then edit *.vbox XML file. Within the CPU tag children (like Hard­ware­Vir­tEx or PAE), replace every enabled="true" with enabled="false".
  • Turn off hardware vir­tu­al­iza­tion via Va­grant­file (config.vm.customize ["modifyvm", :id, "--hwvirtex", "off"])
  • Check if number of CPUs for your Vagrant virtual machine is greater than 1. If so, go and change the count of CPUs in your *.vbox file to one.

Hope this helps.

like image 50
Pedro Lopez Avatar answered Oct 22 '22 03:10

Pedro Lopez