133

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?

Shubham
  • 160
  • 1
  • 4
  • 13
Luke
  • 1,736
  • 2
  • 16
  • 34

17 Answers17

266

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

Cheeso
  • 189,189
  • 101
  • 473
  • 713
Fred
  • 2,676
  • 1
  • 10
  • 5
  • 70
    I found myself in the same situation, I had tar up a tarball from an ubuntu machine. So simply removing the `rm -rf .vagrant` dir that got created in ubuntu also resolved the issue. – Jeff Sheffield Sep 04 '15 at 16:49
  • 1
    // , Wow, thanks, @Fred! Stackoverflow serves us at its best with this kind of precise, difficult to find solution from someone who has had to deal with it before. Where will I usually find the `.vagrant` folder on Unix based machines? – Nathan Basanese Nov 30 '15 at 23:02
  • 1
    Not sure, @Nathan. Can you run a locate command for the creator_uid file? Try "locate creator_uid" at the command line to find the path to the file to edit. – Fred Dec 01 '15 at 19:13
  • // , That worked. I use my CEntOS box from `~/vagrant/centos/`. It looks like the `creator_uid` file was at `~/vagrant/centos/.vagrant/machines/default/virtualbox/creator_uid`. This seems to mean that the `.vagrant` in this answer usually has the same directory as the `Vagrantfile` for the problem machine. – Nathan Basanese Dec 01 '15 at 20:34
  • 4
    In my case, the creator_uid contained "90210", but my UID is 502. Rather than change the UID in the file to 0 as this solution suggested, I changed it to 502. Worked well. – Mr. Lance E Sloan Jan 13 '16 at 21:51
  • Thanks! I created a VM on my Mac, and then had my machine cloned to a new Mac. Everything about the system (other than the improved hardware) behaved the same, as far as I can tell, until I ran into this. Apparently my UID changed from 510 to 502. – olanmills Sep 07 '16 at 22:00
  • 5
    @NathanBasanese `.vagrant` folder is at the same location you ran `vagrant up` – Harish Reddy Feb 10 '17 at 14:17
  • Why can't I find the "creator_uid" file in the given directory? – Wang Jun 21 '17 at 13:52
  • Remove simply `.vagrant` at the root of your Vagrantfile – Jean-Marc Amon Sep 22 '17 at 11:40
  • I worked I had same issue just made change in creatoruid file – user869123 Apr 21 '18 at 07:29
  • It worked, although my vagrant file was at `.vagrant/machines/dev/virtualbox/creator_uid` – Ram Patra Jun 27 '18 at 15:21
37

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.

Chris Cogdon
  • 7,481
  • 5
  • 38
  • 30
  • 16
    This was the issue I faced; however, simply adding `.vagrant` to `.gitignore` will *not* solve the issue - YMMV, but `git rm -rf .vagrant` should be run too. – Marco Massenzio Nov 14 '15 at 02:49
  • @marco: You're absolutely right. if ".vagrant" was added to the repo, adding it to .gitignore afterwards is too late :) – Chris Cogdon Nov 18 '15 at 00:37
8

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.

Canje027
  • 81
  • 1
  • 2
8

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 :)

ConorLuddy
  • 2,217
  • 2
  • 19
  • 18
  • 1
    Same issue here, forgot to run under `sudo`. But the error message is not very indicative of that unfortunately. – Zac Blazic Apr 10 '16 at 20:39
  • 1
    Same here. Used `sudo vagrant up` but then used `vagrant ssh` which threw the different user error. Forgot to use `sudo vagrnt ssh` which worked fine. – Hondaman900 Feb 12 '21 at 22:47
4

just change user ID here .vagrant/machines/default/virtualbox/creator_uid

Oleg Tokar
  • 41
  • 1
  • 1
2

It's possible you ran the command: sudo vagrant up

This would mean as your regular user you are unable to see or even delete the /.vagrant folder and files.

If so, simply run: sudo vagrant destroy -f

Then you should be able to run (as your normal user account): vagrant up

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
brandon
  • 21
  • 1
1

According to the VirtualBox User Manual:

As a security measure, the Linux implementation of internal networking only allows VMs running under the same user ID to establish an internal network.

In other words, you have to switch to root (UID 0) to run it.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
dmargol1
  • 397
  • 1
  • 6
1

Run the following commands:

bash
sudo vagrant up
Enamul Hassan
  • 5,266
  • 23
  • 39
  • 56
vixadd
  • 19
  • 1
1

I faced the same problem. I deleted in .vagrant directory inside the directory where Vagrantfile was present. Then it worked.

abasar
  • 1,659
  • 1
  • 12
  • 7
0

I had the same problem after I got a new computer. Instead of of copying all files from my old computer, I had to check out the vagrant projects again from the git repository. After that, vagrant up worked fine.

0

Just to add on to Fred's https://stackoverflow.com/a/32256848/2065804 answer.

Make sure you changed the correct VM's machine. For example, my VM name is NOT default but rather called homestead-7.

So the path to the correct one is:

.vagrant/machines/homestead-7/virtualbox/creator_uid

and not:

.vagrant/machines/default/virtualbox/creator_uid

This error happened to me when I changed my Mac to another Mac.

Abdul Rahman A Samad
  • 1,062
  • 1
  • 15
  • 21
0

Remove the content of .vagrant hidden dir in the current working dir and re-run vagrant up command. Error, because of copy / backup of Vagranfile /s from one system to another system. user id's mismath to the Vagrant to bring up the environment.. hope it helps cheers..!! :)) if u don't wish to delete that folder u can update uid of current user in file in the hidden dir of current working dir, i.e .vagrant/machines/jenkins/virtualbox$ vim creator_uid

0

I've faced the same situation, but I have a multi-machine Vagrantfile.

To replace the old uid (1001) by the new one (1000) I've used the following command:

for i in $(find . -type f -iname "creator_uid" ) ; do echo 1000 > $i ; done
0

I had the same problem I had forgotten to place sudo before vagrant up, you just have to execute sudo vagrant up in the folder of your vagrant file.

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Luis Matos
  • 21
  • 3
0

I have Multi-Machine vagrant file. I have checked the creator_uid and it is 0 but still unable to load. So I have deleted creator_uid file for all the Multi-Machine and it worked. Path should be .vagrant\machines\<machine_name>\virtualbox

vkrams
  • 7,267
  • 17
  • 79
  • 129
0

I encountered the same issue but it's because I cloned an exercise file from a GitHub repo. I found the issue being the .vagrant file included in the repository.

What worked for me is deleting the .vagrant directory and rerun vagrant up

-2

rm -rf .vagrant/machines/default/creator_uid

Garik
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 04 '21 at 14:54