How to resolve error in running vagrant up on macOS

Viewed 10850

I am using vagrant to setup a ubuntu virtual machine. I have installed virtualbox and vagrant. When I run "vagrant up" I run into following error :

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "268774c3-ac5e-4b96-b17e-99cc4c66b27f", "--type", "headless"]

Stderr: VBoxManage: error: The virtual machine 'profiles-rest-api_default_1536758322698_53584' has terminated unexpectedly during startup with exit code 1 (0x1)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine

After investigating a bit more I found that VMbox is not starting from GUI as well and giving the following error:

Failed to open a session for the virtual machine profiles-rest-api.

The virtual machine 'profiles-rest-api' has terminated unexpectedly during startup with exit code 1 (0x1).

Result Code: NS_ERROR_FAILURE (0x80004005)
Component: MachineWrap
Interface: IMachine {85cd948e-a71f-4289-281e-0ca7ad48cd89}

When I tried to install it with brew cask install virtualbox, I recieved the following error:

Error: Failure while executing; /usr/bin/sudo -E -- env LOGNAME=username USER=username USERNAME=username /usr/sbin/installer -pkg /usr/local/Caskroom/virtualbox/5.2.18,124319/VirtualBox.pkg -target / exited with 1

4 Answers

Are you using Mojave? There's a known issue with it.

Do the following:

  1. Update VirtualBox to the latest version. I'm not sure of which one works, but 5.2.10 didn't work for me whilst 5.2.18 did.
  2. Grant iTerm, Terminal or whatever you use to boot your box Full Disk and Accessibility access, as per this thread
  3. Restart iTerm
  4. vagrant up

Good luck!

If you are mac os user, check your macbook's setting --> security

as default, it blocks the application running from oracle, just allow and approve it, this problem is gone.

enter image description here

I upgraded my macOS to Monterey v12.0.1 and started having trouble with VirtualBox (no VMs would start) and found a temporary solution of reinstalling VirtualBox. Then vagrant wasn't able to start VMs with the same error in the original question. This is what worked for me:

I modified the vagrant file to start the VM with a GUI instead of headless. Reference

brew cask install virtualbox
# https://support.intego.com/hc/en-us/articles/115001273551-Intego-Extensions-Blocked-in-macOS
# Click "Allow" per 2. Click the 'Allow' Button
brew cask install virtualbox
Related