A VirtualBox machine with the name 'homestead' already exists
Asked Answered
B

32

128

Since homestead 2.0 homestead laravel has not been working

I don't know why 'homestead init' creates a Homestead.yaml file in mydirectory/.homestead and not in the project directory. Homestead up OR Vagrant up create the following message

A VirtualBox machine with the name 'homestead' already exists.

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
A VirtualBox machine with the name 'homestead' already exists.
Please use another name or delete the machine with the existing
name, and try again.
Burner answered 18/11, 2014 at 12:2 Comment(3)
This can happen when you delete directly from the filesystem without informing Vagrant and/or VirtualBox. Try VBoxManage list vms and see if there is a ghost/orphan/zombie entry that needs to be expunged.Evocator
For homestead specific answer - see answer from @TheSteedCrusted
github.com/hashicorp/vagrant/issues/6623#issuecomment-160980634Foreclose
C
312

I solved by using vboxmanage to get the ID of the VM.

$ vboxmanage list vms
"my-vm" {c700b8b6-b766-4638-871b-736b44b7db18}

Copy the ID of the desired VM (the c700…db18 string) into the contents of ~/.vagrant/machines/default/virtualbox/id. Save the file then run vagrant up to get the vm working without having to destroy it.

Condenser answered 18/6, 2015 at 8:32 Comment(18)
Agreed. The vagrant destroy worked for me before but the 2nd time it didn't work. This method definitely does.Pirtle
Just to note, that if you named your box differently via define (like me), then the path will not be ../default/ , its : .vagrant/machines/<box name>/virtualbox/id. #profit!Ruthven
Worked like a charm. Just curious why the id of my vm suddenly changed and this was necessary at all.Academia
In os x it's "VBoxManage list vms"Nydia
On my dev environment, the id file was on the the same path, but on the root of the project. At project-root/.vagrant/machines/default/virtualbox/idJebel
I almost delete my machine thankfully i found this. By the way, .vagrant is located where your vagrant is, as for my case its on 'Homestead' folder.Catholicism
For me the .vagrant folder was not in ~/ but in the homestead installation folder (i.e. the folder you run vagrant up from)Rotund
for me /default suddenly changed to /project name here so i just renamed /default to /project name here and suddenly it worked. i don't even know why it does not use /default anymore.. well.. thanks to this answer i could solve this problem.Lima
FYI on my mac using Vagrant.~ My location ended up being ~/Documents/Vagrant/.vagrant/machines/<BOX_NAME>/virtualbox/idLudwick
Or you could just add the following to your YAML file: name: my-box-nameConversationalist
On Windows I retrieved machine id from %USERPROFILE%\VirtualBox VMs\<MACHINE>\<MACHINE>.vbox then it worked for me.Related
This is not the best way to go if you have multiple VMs on the same machine. Changing the name it is creating is the best way to avoid conflicts as you are then using an already provisioned machine.Santonin
After using this advice, (and upgrading vagrant from 1.7.x to 1.8.1), I got this error when doing a vagrant up: Warning: Authentication failure. Retrying.... In macOS terminal, I was able to ctrl+c out, and then do a vagrant ssh and use vagrant as password. Probably doing something wrong. But… I only touch vagrant once every three years (when something goes wrong).Overmatch
it's a different problem related to your ssh id_rsa key @OvermatchCondenser
@Condenser Thank you! I took a shotgun approach and this https://mcmap.net/q/142091/-vagrant-ssh-authentication-failure fixed my issue.Overmatch
What I did was to open VirtualBox and delete the VM "Homestead-7". Then I tried again $ vagrant up, and that did the trick ☺Millymilman
I had this happen with Parallels. To get the VM ID there run prlctl list --all.Constrain
The path is actually where your vm is installed. For me, on my mac, the vagrantfile is on "/Users/myname/webdev/mywebsite-local" . So the "id" file is then in ".vagrant/machines/mywebsite-local/virtualbox". So the final path is "/Users/myname/webdev/mywebsite-local/.vagrant/machines/mywebsite-local/virtualbox/id"Tonicity
L
83

For me, the machine was not showing up as an active VM in the VirtualBox application. To fix I had to do this:

vagrant global-status

This gave me the ID of the machine that I needed to destroy. With the ID, run:

vagrant destroy {VM ID}

I had to run that in sudo to actually destroy the machine. At that point, I was able to run

vagrant up

Loam answered 4/12, 2014 at 20:49 Comment(3)
If your homestead box is corrupted, not already running, this is the answer for you. Verified on Ubuntu 14.02 running VirtualBox.Pirtle
This is useful because it shows you the directory of running vagrant VMsCoif
The command vagrant destroy vm_id must be run from within the same directory.Tyrant
U
61

From the following message :

A VirtualBox machine with the name 'vm_name' already exists. Please use another name or delete the machine with the existing name, and try again.

I listed current running virtual machines from the command line :

VBoxManage list vms

Result :

"vm_name" {8ba467b7-da96-4f68-9bf8-671dd6f0d007}

Then proceeded with the removal of the offending virtual machine :

VBoxManage unregistervm 8ba467b7-da96-4f68-9bf8-671dd6f0d007 --delete
Unwind answered 3/1, 2016 at 20:22 Comment(3)
The only answer that shows how to delete a VM from the command lineCentrosome
Note that this won't work if the VirtualBox VM is still running. The VM has to be shut down or else the command will fail "because the VM is locked."Bhutan
Yes and the command would be poweroff. Summary of what worked for me: vboxmanage list vms, vboxmanage controlvm <id> poweroff, vboxmanage unregistervm <id> --deleteTakeover
S
45

You probably have a virtualbox running! Open the programme virtualbox and shut down the other virtualbox ;) http://smallbusiness.chron.com/shut-down-virtualbox-43657.html

If this isn't working then you might want to delete the old homestead folder and place all your projects in the new folder ;)

Stafani answered 18/11, 2014 at 12:17 Comment(0)
C
41

I'm a bit late to the party on this, but for anyone else having this issue SergioPeluzzi came closest, but didn't get the cigar with this:

Seek for vb.name = settings["name"] = "homestead" line and changed "homestead" to "HOMESTEAD" and "vói lá"

The line is actually:

vb.name = settings["name"] ||= "homestead"

As you can see from the bit that says settings["name"], you just need to add a name field to your Homestead YAML file, e.g.

memory: 2048
cpus: 1
provider: virtualbox
name: my-sexy-homestead-box
Conversationalist answered 1/3, 2017 at 11:40 Comment(5)
This is the best answer if you're actually installing and using multiple Homestead instances.Rota
I agree with @Rota this is the best answer if you are working with multiple Homestead instancesNordin
The key is name: my-sexy-homestead-box -- Thanks!Bellwether
Far away the best answer!Feininger
This is the correct answer. The other answers are not correct (and in fact will mess up your installation) if you have multiple instances of Homestead going.Gymnosperm
Y
25

I edited Homestead.yaml and add new name for it

ip: "192.168.10.10"
memory: 2048
cpus: 4
provider: virtualbox
name: my-new-homestead-box-name
Yearround answered 27/1, 2018 at 3:17 Comment(3)
This is the correct way to do it. homestead.rb config first looks for the name variable in homestead.yamlMunch
I was trying to get another homestead running. Never thought it would be this easy. Just add a name in Homestead.yamlIngrate
Agreed. This was a simple answer that pulled me out of the Linux-VirtualBox-Vagrant-Laravel-Homestead quicksandDrice
A
17

I solved this editing /Homestead_folder/scripts/homestead.rb

Seek for vb.name = settings["name"] = "homestead" line and changed homestead to HOMESTEAD and "vói lá" that worked for me.

Agan answered 8/10, 2015 at 15:25 Comment(2)
This works. Search this file for all records vb.name = settings['name'] and change acordinglyCamphor
see answer from @TheSteedCrusted
B
11

I had an old .vagrant directory in my project which was causing the error :)

If this doesn't fix it for you i would suggest opening VirtualBox and removing all VirtualBoxes and trying again.

Burner answered 18/11, 2014 at 12:37 Comment(1)
That was it. After doing "vagrant box update" I had to remove that .vagrant directory and re-run vagrant up.Powel
B
10

You just have to add the key name to your homestead.yaml file right after the provider like this:

name: name_of_you_machine

That works for me.

Blouson answered 4/8, 2020 at 3:37 Comment(1)
This is what I've been looking for. Very useful when you want to try other Homestead's versions. Where do we place this? Check the answers below :PMillymilman
P
8

I had same issue today. Spend few hours to find the solution. If by any reason you can't find the list of exiting virtual machines then type in terminal

sudo virtualbox

This will run Virtual Box in GUI. You should see the the full list of VMs and from there you'd be able to manage them. Typing "virtualbox" only won't show anything. You need to be root (administrator).

Thanks to mightyspaj for the tip.

Preconscious answered 31/10, 2015 at 13:36 Comment(2)
Using the regular virtualbox app on OS X, I could not see any VM's in a list even though I was being told it already existed. Then I typed sudo virtualbox and saw a whole heap of VM's and the problem was fixed. Thank you.Usurious
Never ever use sudo with VirtualBox. You are going to screw up permissionsPaulsen
S
8

Commands to execute:

vagrant box list
vagrant box remove laravel/homestead
vagrant global-status
vagrant destroy nameOfYourBox

Open your VirtualBox and delete all itens of your homestead

vagrant up
Shingle answered 14/11, 2017 at 17:31 Comment(0)
V
7

I opened the virtualBox and then deleted homestead vm that was created earlier. It helped.

Voltmeter answered 20/11, 2014 at 9:58 Comment(0)
I
7

I was receiving the same error message, even after running "homestead destory", and "vagrant destroy". Same as you, I was using the VirtualBox provider, vagrant, and homestead. Here's what I did:

  1. Opened VirtualBox GUI. I see "homestead" as a VM, but I cannot remove it, button is greyed out.
  2. I logged out of my OS, logged back in and re-opened VirtualBox. Status is now "aborted" and i'm able to remove.
  3. There were some residual files in ~/VirtualBox\ VMs/homestead, so i ran rm -r /Users/gabriel/VirtualBox\ VMs/homestead
  4. I am now able to run "homestead up"
Ineslta answered 29/11, 2014 at 22:5 Comment(0)
S
4

Open VirtualBox GUI. See for your VM and remove it. It solved my problem.

Slippy answered 28/2, 2017 at 8:14 Comment(0)
M
4

None of this worked for me. I was using an old dev machine

I attempted:

  1. vagrant global-status > destroy any by id which you don't need or match what is conflicting

  2. open virtualbox and remove + delete files for any which you don't need or are conflicting

What worked:

  • locate your ~/.vagrant/machines/ or ~/.vagrant.d/boxes folder. In my case, it contained the conflicting vm and also a bunch of old left over vm machines which steps 1 & 2 did not remove for some reason.

  • after clearing these, everything worked fine again, finally!

Maladminister answered 11/3, 2017 at 12:57 Comment(3)
This is a great answer if the conflicting VM is OK to be removed/cleared out. This answer should be amended now that the folder is ~/.vagrant.d/boxes/ @MaladministerRota
@Rota just added :)Maladminister
Thanks! Solved the problem for me!Retch
L
4

Windows10

Edit Homestead.yaml file and give a new name for the box:

ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
name: my-new-vbox      #new name for the box

and run vagrant up or vagrant up --provision

Or

Open Virtualbx application in GUI and delete all the virtualbox that was causing problem and run the above command

Or

Delete the "Vagrant" file inside homestead folder and run the above command.

Leonoraleonore answered 4/4, 2020 at 1:0 Comment(0)
U
3

Sometimes you might not want to delete old box. Yesterday may old Vagrant has broken, I've updated Vagrant and Virtualbox but folders mapping didn't work. I wanted to run new box and had this error.

I didn't want to remove old box (because I wanted to run some backups) but I wanted to run new box. The solution was running VirtualBox, right click on Homestead machine and choose Settings and then changing name from homestead to homestead_old.

After that I was able to install homestead but had this old machine and could also run this to make any backups I needed.

Homestead change name in Virtualbox

Uptodate answered 12/11, 2015 at 19:35 Comment(0)
T
3

If you are a Windows User, make sure you delete C:\Users\<Username>\VirtualBox VMs\homesteadfolder. Because if there is still a folder named homestead, the action of vagrant up will not be completed

Target answered 7/4, 2016 at 10:22 Comment(1)
In my case, I had two folders: homestead and homestead-7. After deleting both, problem solved. Thanks!Afterdeck
F
3

If you want to keep keep your machine, without destroying and recreating following steps should solve your problem. (I work on OS X El Captain, Vagrant 1.8.1)

Run homestead in debug mode

homestead --debug up

Look for something like in the output:

INFO machine: Initializing machine: default INFO machine: - Provider: VagrantPlugins::ProviderVirtualBox::Provider INFO machine: - Box: # INFO machine: - Data dir: /Users/YOUR_HOME_DIR/Workspace/Homestead/.vagrant/machines/default/virtualbox

Data dir, is the path which is interesting for you.

Then vboxmanage list vms

"homestead" {0e8438b9-4a67-4fb1-80cb-2c62cf04ab5c} "settler_default_1447385930122_73498_1474294682778_13108" {93ecb93f-f159-4406-a384-5312b4d3ab34}

Edit id file, in the path which you found out in the previous command

vi /Users/YOUR_HOME_DIR/Workspace/Homestead/.vagrant/machines/default/virtualbox/id

Replace content of that file, with the id of the VM you want to fix, in this scenario it is

0e8438b9-4a67-4fb1-80cb-2c62cf04ab5c

Now try

homestead up

VM should start booting. It might work, or you might have issues with ssh authentication

default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Authentication failure. Retrying...     default: Warning: Authentication failure. Retrying...

To fix that do following Check Homestead SSH config

homestead ssh-config

You should get something like

Host default HostName 127.0.0.1 User vagrant Port 2222
UserKnownHostsFile /dev/null StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile "/Users/pryznar/.vagrant.d/insecure_private_key"
IdentitiesOnly yes LogLevel FATAL

Edit IdentityFile file

/Users/YOUR_HOME_DIR/.vagrant.d/insecure_private_key

Check Homestead.yml

cat /Users/YOUR_HOME_DIR/.homestead/Homestead.yaml

Then copy path to the file under the key keys, and copy private key from that file

cat ~/.homestead/ssh/id_rsa

Last step is to replace private key in /Users/YOUR_HOME_DIR/.vagrant.d/insecure_private_key with the one you just copied

Now try rung homestead again, should work.

homestead up

I got some warnings, but so far it works without issues

==> default: Warning: Using a password on the command line interface can be insecure. ==> default: ERROR 1045 (28000): Access denied for user 'homestead'@'localhost' (using password: YES) The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what went wrong.

Fibrosis answered 20/9, 2016 at 9:19 Comment(0)
A
3

You can open the VirtualBox GUI and remove the conflicting virtual machine.

Agreeable answered 27/3, 2017 at 18:41 Comment(0)
P
2

I had the following error:

Error:

A VirtualBox machine with the name 'homestead-7' already exists.
Please use another name or delete the machine with the existing
name, and try again.

Solution:

  • Find the VirtualBox VMS folder, in my case it was in ~/VirtualBox VMs
  • List the elements in the folder with ls command, and review if the virtual machine is there
  • Delete the folder with the name of the machine, in my case homestead-7
  • Re-execute the vagrant up command in the homestead folder

That's all, I hope it's helpful, that was my solution.

Regards!

Pantia answered 13/11, 2018 at 19:8 Comment(0)
O
1

In my case the following article provide the solution. There was a folder named homestead inside the path /var/root/VirtualBox VMs/ that was causing the issue. Once this folder was removed, rm -r homestead, the issue was resolved. If you can not see or have access to this path execute the following commands in your terminal windows:

$ sudo -s 
$ cd /var/root/VirtualBox\ VMs

And proceed to delete the homestead folder.

Oyler answered 14/7, 2015 at 6:30 Comment(0)
R
1

Add --force after box, and before your given name.

Recognizee answered 21/12, 2017 at 1:13 Comment(1)
Please edit your answer to explain why you think this solution will work, what it does and how. Also it's worth formalising your English (though I appreciate that English is probably not your first language), though I've edited your answer to correct and tidy that.Fontanel
V
1

Renaming an already existing default VM

Disclaimer

The following procedure will destroy your VM and may be only suiteable in a desting-environment like mine! For production environments, consider to repair the association like described here

I had this problem after overriding the default name of an already existing VM by using

Vagrant.configure("2") do |config|
  config.vm.define :ubuntu_test

where the VirtualBox name was also set (as a newbie I assumed that Vagrand will use this name too)

config.vm.provider "virtualbox" do |vb|
     vb.name = "Ubuntu-Test"
end

By adding config.vm.define it seems that Vagrant doesn't associate the VirtualBox VM any more with the Vagrant file since even vagrant destroy -f say VM not created but vagrant up throw this error

A VirtualBox machine with the name 'Ubuntu-Test' already exists.

To delete those zombie VM
  1. If the VM is running, stop it first: vboxmanage shutdown <VMName> (Here the name is Ubuntu-Test)
  2. Get the Id by running vboxmanage list vms
  3. Delete it: vboxmanage unregistervm <Id> --delete
  4. Now your VM can be re-created using vagrant up
  5. Using vagrant global-status --prune, your new name is present
Veinstone answered 28/10, 2018 at 13:56 Comment(0)
M
1

For me id file was present in the below-mentioned location. D:\drupalvm.vagrant\machines\drupalvm\virtualbox

Melvinamelvyn answered 13/12, 2018 at 7:1 Comment(0)
I
0

After a few hours of troubleshooting, nothing else worked for me, as no one mentioned this little detail.

Depending on your privileges at the time of installation, you may need to run virtualbox as an administrator. It was only when I did this that I saw my vagrant boxes in the list of virtual machines.

I then proceeded to remove my virtual machine named homestead from virtualbox, and the problem was solved.

Infanta answered 16/10, 2015 at 23:53 Comment(0)
H
0

If you're using homestead in Windows, just open up your Oracle VM VirtualBox and delete the homestead VM.

Hammy answered 8/11, 2015 at 14:48 Comment(0)
M
0

The Vagrant relies on VirtualBox (if that's the default provider) so it checks for existing environment first before provisioning your VM.

It is executing the following command:

VBoxManage list vms

and when it finds the VM with the same hostname, so it'll fail.

You can debug it by:

vagrant --debug up

to find out the exact reason.


Solution

If you're planning to use multiple VMs in different folders, then you need to change your config.vm.hostname (possibly config.vm.provider(name) as well) in your Vagrantfile to make it unique. Or simply remove it, so Vagrant will assign a different name for each VM.

If that's not the case, simply shutdown and unregister previous VM which conflicts by running:

VBoxManage controlvm NAMEOFVM poweroff
VBoxManage unregistervm NAMEOFVM --delete

and re-run your vagrant up.

If it fails on directory rename (because you missed --delete), then rename or remove the destination folder, for example:

rm -fr ~/"VirtualBox VMs/NAMEOFVM"

and re-try again.


This problem may be related to: GitHub issue #2969 - vagrant up not detecting a previously run VM

Micropyle answered 17/3, 2016 at 15:11 Comment(0)
S
0

In my case, nothing was indicating that the VM "already exists" besides that error message. Nothing on VirtualBox UI, nothing returned by “vboxmanage list vms”, nothing through “vagrant global-status”, it didn’t exist in “.vagrant.d\boxes” and so on. I resolved it by manually creating a new same-name VM in the VM VirtualBox Manager (using the “new” button + accepting all the defaults), and then removing it (right-click > remove). After that, the “vagrant up” worked as expected.

Scop answered 6/12, 2016 at 0:3 Comment(0)
S
0

I had the same issue today. Windows 10. I recently had updated Homestead, so the error was probably because of that. I tried it all, destroy, up, delete folders, whatever. Whenever I tried to run vagrant up, it was showing this kind of errors. The solution? After updating, I noticed that Homestead is now naming the boxes by the project folder name, and Homestead.yaml has all that infos. I just run that Homestead Windows configuration vendor\\bin\\homestead make and later them a vagrant up (before making sure it was all clean) and voilá, looks like the machine is booting now. =) Try that if you need it.

Stoss answered 19/12, 2016 at 15:28 Comment(0)
L
0

VBoxManage: error: Could not rename the directory '/Users/xxxx/VirtualBox VMs/ubuntu-20.04-amd64_xxxxxxx' to '/Users/xxxx/VirtualBox VMs/homestead' to save the settings file (VERR_ALREADY_EXISTS)

Removing /Users/xxxx/VirtualBox VMs/homestead manually sort this out for me in mac

Larrainelarrie answered 12/11, 2021 at 0:57 Comment(0)
K
-1

None of the above ended up working for me. My final solution was to:

cd ~/.composer/vendor/laravel/homestead/.vagrant/machines;
rm -R default;
cd /var/www/path/to/project;
homestead up;
Kephart answered 2/12, 2014 at 2:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.