- Published on
Fix Vagrant Box Hanging at Boot
- Authors

- Name
- Kevin van Zonneveld
- @kvz
Sometimes it happens that vagrant hangs during boot of your virtual image. Right after typing:
$ vagrant up
It hangs for a long time and then finally throws:
[default] Failed to connect to VM!
Failed to connect to VM via SSH. Please verify the VM successfully booted
by looking at the VirtualBox GUI.
If you open VirtualBox you'll see that the virtual machine preview shows a black screen with kernels to choose from. This is GRUB requiring user input to boot further.
Here's how to fix that.
First, get the machine id
$ # Before v1.1
$ # MACHINE_ID=$(awk -F\" '{print $6}' .vagrant)
$ # After v1.1
$ MACHINE_ID=$(cat .vagrant/machines/default/virtualbox/id)
Power off the VM
$ VBoxManage controlvm ${MACHINE_ID} poweroff
Then boot the machine with a GUI console
$ VBoxManage startvm ${MACHINE_ID}
Wait for it to boot, login, run:
$ sudo update-grub
When successful, shut it down
$ VBoxManage controlvm ${MACHINE_ID} poweroff
And after this, vagrant up will just boot your VM normally :)
Legacy Comments (7)
These comments were imported from the previous blog system (Disqus).
Awesome! Solve my problem, many many thanks!
How to connect to guest OS, if it is not loaded?
Hi Kvz,
I followed your instruction till VBoxManage startvm ${MACHINE_ID} this command.
My Virtualbox gets started as well, but still there is nothing in that apart from blank screen.
Hi, a good way to debug is to open VirtualBox and take a look at the screen preview. You'll see where exactly the box is hanging
Hi, thanks for reply, In the beginning it says "Press F12" which we get in normal computer startup. From few seconds it disappears and shows black screen with nothing on it.
Genius! Thanks Kevin.