I have a Ubuntu 14.04 Vagrant box. It seems to work fine most of the time, however every couple of days I'll get a problem. When Vagrant is trying to ssh into the machine, it gets a
Warning: Remote connection disconnect. Retrying...
This is printed every few seconds for a while until I'm given an error saying it timed out waiting for the machine to boot. I found this question which suggested booting into the gui with:
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
to see what was holding the VM up. It looks like the VM is getting stuck calling url_helper.py
:
url_helper.py[WARNING]: Calling 'http://169.254.168.254/2009-04-04/meta/instance-id'
failed [101/120s]:request error [(<urllib3.connectionpool.HTTPConnectionPool object
at 0x7ff2d6691450>, 'Connection to 169.254.168.254 timed out.
(connect timeout=50.0)')]
url_helper.py[WARNING]: Calling 'http://169.254.168.254/2009-04-04/meta/instance-id'
failed [119/120s]:request error [(<urllib3.connectionpool.HTTPConnectionPool object
at 0x7ff2d6682f50>, 'Connection to 169.254.168.254 timed out.
(connect timeout=50.0)')]
DataSourceEc2.py[CRITICAL]: Giving up on md from
['http://169.254.168.254/2009-04-04/meta/instance-id'] after 120s
This continues getting printed out until Vagrant fails:
<machine name>: Warning: Remote connection disconnect. Retrying...
<machine name>: Warning: Remote connection disconnect. Retrying...
<machine name>: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that Vagrant was
unable to communicate with the guest machine within the configured
("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that Vagrant had
when attempting to connect to the machine. These errors are usually good hints
as to what may be wrong.
If you're using a custom box, make sure that networking is properly working and
you're able to connect to the machine. It is a common problem that networking
isn't setup properly in these boxes. Verify that authentication configurations
are also setup properly, as well.
If the box appears to be booting properly, you may want to increase the timeout
("config.vm.boot_timeout") value.
but then a little while later will continue onto the login screen. At this point I can log in or ssh in, except some things aren't right. ie. the shared folders aren't mounted. The only solution I can find to this is to destroy and re-up the machine:
vagrant destroy -f && vagrant up
Which can take a while depending on the provisioning of the machine.
Has anyone else come across this problem before? Any suggestions on how to fix this?
Here is my current Vagrantfile:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "trusty64"
config.vm.box_url = "/media/resources/Development/Vagrant/Boxes/trusty64.box"
config.vm.define "name" do |name|
name.vm.hostname = "name"
name.vm.network :private_network, ip: "192.168.45.12"
name.vm.network :forwarded_port, guest: 7070, host: 7070
name.vm.network :forwarded_port, guest: 7443, host: 7443
name.vm.provider :virtualbox do |vb|
vb.name = "name"
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "provisioning/playbook.yml"
ansible.sudo = true
ansible.verbose = "v"
ansible.extra_vars = "@provisioning/user_vars.yml"
end
end
By the way, the other answer to the linked question above (sending the enter key to the virtual machine through vboxmanage
didn't work since I have a different problem to the asker of that question.)
UPDATE: Following @ElfElix's advice I had a look in /etc/network/interfaces and saw this:
#VAGRANT-BEGIN
#The contents below are automatically generated by Vagrant. Do not modify
auto eth1
iface eth1 inet static
address 192.168.45.11
netmask 255.255.255.0
#VAGRANT-END
Although, in /etc/network/interfaces.d/eth0.cfg is:
# The primary network interface
auto eth0
iface eth0 inet dhcp
I tried removing this file to disable DHCP, but that just made it worse. Not only did the vagrant up
fail, because it couldn't connect, but I was unable to ssh in after waiting a while.
Does anyone have any other ideas?
UPDATE II:
It appears that the VM will only start after the initial vagrant up
which will create and provision the machine. After halting the machine, it will no longer come up correctly since it encounters the above error.