Vagrant troubleshooting

Vagrant troubleshooting



Restarting Virtualbox

Sometimes if VMs won't boot, this does the trick:

sudo /Library/Application\ Support/VirtualBox/LaunchDaemons/ restart

If you are running the VirtualBox desktop app, close it and wait 30 seconds before running this command.

Problem: "The following SSH command responded with a non-zero exit status."

You see a message like this when (re)booting one of your VMs:

The following SSH command responded with a non-zero exit status.

Vagrant assumes that this means the command failed!

/sbin/ifdown eth1 2> /dev/null

Stdout from the command:


SSH into the VM (this should work despite the above message) and do the following:

# 1. Backup /etc/network/interfaces file:
sudo cp /etc/network/interfaces ~/interfaces-bak
# 2. Edit /etc/network/interaces and delete all the sections beginning "#VAGRANT-BEGIN" and ending "#VAGRANT-END":
sudo vim /etc/network/interfaces

Come out of the VM and reload it with "vagrant reload".

Problem: Vagrant up hangs on "d6phx: Warning: Connection timeout. Retrying..."


This is often because the machine has rebooted and is waiting for a keypress on the boot options screen. Sometimes you can see this by starting VritualBox and looking at the small visualisation of the VM's screen.

To solve this, send an "enter" keystroke to the VM like this:

# Find the id of the box that is hanging
> vboxmanage list runningvms
"multi_nginx_1412756128427_77437" {5886ab44-3faa-4170-b17f-1f31c7ffd48f}
"multi_varnish_1412756566156_94034" {a68650fc-8b9a-46b6-ac79-dcd33857f53a}
"multi_d7_1414064745239_6304" {005e6773-7477-414d-bbfe-23744b3468cc}
"multi_db_1425890895546_92575" {b6e0b3f0-92d5-42c8-a5d2-6ec65f126d60}
"multi_d6phx_1428485040860_27963" {afd2ae2d-927e-46a3-b294-0862d1723d68}

# Send the "enter" key to the hanging VM:
vboxmanage controlvm multi_d6phx_1428485040860_27963 keyboardputscancode 1c

Problem: "Can't remove kext org.virtualbox.kext.VBoxDrv" when restarting Vagrant

Sometimes when restarting Vagrant you may see a message like this:

sudo "/Library/Application Support/VirtualBox/LaunchDaemons/" restart
Unloading VBoxNetFlt.kext
Unloading VBoxDrv.kext
(kernel) Can't remove kext org.virtualbox.kext.VBoxDrv; services failed to terminate - 0xe00002c7.
Failed to unload org.virtualbox.kext.VBoxDrv - (iokit/common) unsupported function.
Error: Failed to unload VBoxDrv.kext
Fatal error: VirtualBox


Instead of "restart", use "stop" and then "start":

sudo "/Library/Application Support/VirtualBox/LaunchDaemons/" stop
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/" start

Solution 2

Force kill vbox processes and then run the restart command above.

# List vbox processes
ps aux | grep -i vbox
# Force-kill the "VBoxHeadless" process:
kill -9 123456
# Restart
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/" restart

Problem: "Vagrant cannot forward the specified ports on this VM..."


It often works to do a "vagrant reload" on all the suspended (and perhaps running) boxes.

Problem: "Vagrant execute the capability 'change_host_name' on the detect guest OS 'linux', but the guest doesn't support that capability."


This is It will be fixed in the next release, until then if its blocking you, you can patch vagrant yourself by the following step:

Problem: "Vagrant SSH Authentication failure..."


Vagrant changed the behaviour between 1.6 and 1.7 versions and now will insert auto generated insecure key instead of the default one.

You can cancel this behaviour by setting config.ssh.insert_key = false in your Vagrantfile.