Troubleshooting A VirtualBox machine with the name 'dev' already exists.
I just had the weirdest thing happen to me. I was working as usual in my vagrant box when I was suddenly kicked out. No explanation, just lost the connection. After that I was unable to log in again using
vagrant ssh, as you can see below in the console output.
vagrant@vagrantbox:~/$ Connection to 127.0.0.1 closed by remote host. Connection to 127.0.0.1 closed. troels@host:~/workspace/drupal-vagrantbox$ vagrant ssh ssh_exchange_identification: Connection closed by remote host troels@host:~/workspace/drupal-vagrantbox$ vagrant status Current machine states: default not created (virtualbox) The environment has not yet been created. Run `vagrant up` to create the environment. If a machine is not created, only the default provider will be shown. So if a provider is not listed, then the machine is not created for that environment.
At first I figured it was probably just a fluke, so I did
vagrant up, and Vagrant tried to build the machine again, however it already existed (i.e. I could find it in VirtualBox), so Vagrant failed creating it anew. But it still knew nothing about the box.
troels@host:~/workspace/drupal-vagrantbox$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'hashicorp/precise64' is up to date... ==> default: There was a problem while downloading the metadata for your box ==> default: to check for updates. This is not an error, since it is usually due ==> default: to temporary network problems. This is just a warning. The problem ==> default: encountered was: ==> default: ==> default: Couldn't resolve host 'vagrantcloud.com' ==> default: ==> default: If you want to check for box updates, verify your network connection ==> default: is valid and try again. A VirtualBox machine with the name 'dev' already exists. Please use another name or delete the machine with the existing name, and try again.
Bugger. What to do?
What I had to do was find the id of the vbox in the VirtualBox configuration, which was located in this file
~/VirtualBox VMs/dev/dev.vbox in the
uuid for the
Machine tag. I copied it and replaced the value in
~/workspace/drupal-vagrantbox/.vagrant/machines/default/virtualbox/id with the actual/new value from the
.vbox file. Then I ran
vagrant up again the the machine booted as usual.
Just a note: I made sure that the machine was powered off using the VirtualBox application, and then closed the VirtualBox application to make sure that there were nothing interfering with Vagrant.