Fix vagrant can’t recognize VM and create new VM problem

Vagrant (www.vagrantup.com) has been my favorite VM manager for development purposes. It’s generally fast, highly-configurable and easy-to-use. Vagrant is based on VirtualBox (www.virtualbox.org), of which the combination sometimes causes problems.

For example, there are times when vagrant couldn’t recognize the existing VM in the folder, and keeps creating new VMs. This typically, but not reliably so, happens after I upgraded VirtualBox/ Vagrant or changed VM stored location. I’ve drawn out steps to fix this in my machine.

  1. First vagrant halt
  2. Open VirtualBox. Find your old VM that you want to re-associate and the wrongfully created new VMs. Right click the old VM and select "Show in Explorer"
  3. In the folder that's opened, find you-box-name.vbox-prev and open with text editor. Note the <Machine uuid="{e719d311-3721-41a8-90ce-73a6cdaecb89}"  part
  4. Now go to the original directory where your VM is supposed to be called up. Expand .vagrantmachinesdefaultvirtualbox and open id file with texteditor. Replace the uuid inside with the old VM uuid

In case the above does not work for you, check these useful links:

Re-associate vagrant with vm

Vagrant is always creating a new VM

How do I associate a Vagrant project directory with an existing VirtualBox VM?

Written on January 19, 2014