Vagrant Not Starting Up. User that created VM doesn't match current user

I was trying to start up my vagrant machine, so I navigated to the folder where my vagrantfile is, and used:

vagrant up && vagrant ssh

but I got the following error message:

The VirtualBox VM was created with a user that doesn't match the current user running Vagrant. VirtualBox requires that the same user be used to manage the VM that was created. Please re-run Vagrant with that user. This is not a Vagrant issue.

The UID used to create the VM was: 0 Your UID is: 501

I also tried with sudo, but that didn't work either.

Do I need to switch UID's? And how would I do this?


Solution 1:

I ran into the same problem today.
I edited my UID by opening the file .vagrant/machines/default/virtualbox/creator_uid and changing the 501 to a 0.

After I saved the file, the command vagrant up worked like a champ.

NB: the .vagrant folder is in the same directory as your Vagrantfile, where you ran vagrant up

Solution 2:

Ran into this problem in a slightly different situation. The issue was that ".vagrant" was checked into the git repo, and the committer was running under a different UID than I was.

Solution: add .vagrant to .gitignore.

Solution 3:

I ran into the same issue, but in my case it was because I had ran vagrant up under sudo, and when I came back to it later I'd forgotten.

Silly mistake, but I'm sure it's not the first time it's happened someone :)

Solution 4:

I tried changing the id in .vagrant\machines\default\virtualbox\creator_uid and that did not work for me but deleting the file, creator_uid did the trick.