Running Vagrant via “vagrant up” on macOS Monterey (12.0.1) fails
Expanding on @Giacomo1968's answer, which got me very close. (Thank you!)
This specific comment really helped me. https://github.com/hashicorp/vagrant/issues/12557#issuecomment-954704523
Here are the steps I took to fix:
-
Add the following to Vagrantfile in the
config.vm.provider
sectionv.gui = true
-
Create a file as sudo:
/etc/vbox/networks.conf
-
Paste the following in the networks.conf:
* 0.0.0.0/0 ::/0
-
Then run this:
sudo kextload -b org.virtualbox.kext.VBoxDrv && sudo kextload -b org.virtualbox.kext.VBoxNetFlt && sudo kextload -b org.virtualbox.kext.VBoxNetAdp && sudo kextload -b org.virtualbox.kext.VBoxUSB
Then vagrant up
!
This is a known issue and seems to be related to VirtualBox version 6.1.28.
The issue has been solved with the release of VirtualBox version 6.1.30.
There is a healthy and detailed thread in the official HashiCorp repo for Vagrant about this: “Vagrant up issues in Mac OS Monterey #12557”
The issue seems 100% unrelated to VirtualBox 6.1.28 or even the earlier 6.1.26 since people report the same overall behavior.
Note the specific error you have posted:
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "047f549a-e0be-48d9-93d5-6b1958594689", "--type", "headless"]
The command that is failing is the default headless
option for staring VMs via Vagrant. And the only work-around for now is to set the startup option to gui
instead of headless
.
As explained in the official Vagrant docs:
GUI vs. Headless
By default, VirtualBox machines are started in headless mode, meaning there is no UI for the machines visible on the host machine. Sometimes, you want to have a UI. Common use cases include wanting to see a browser that may be running in the machine, or debugging a strange boot issue. You can easily tell the VirtualBox provider to boot with a GUI:
config.vm.provider "virtualbox" do |v| v.gui = true end
So just find the config.vm.provider "virtualbox" do
block in your Vagrantfile and set that v.gui = true
and it should work now; albeit with a GUI popping up which might be a wee bit annoying.
That said, another user in that issue thread states that config.vm.network
networking commands might not work.
So this all might boil down to this being fixed in Vagrant 2.2.19? Or maybe VirtualBox is misbehaving as well?
Confusing and annoying, but hopefully this helps in some way.
UPDATE: It seems to be an issue in VirtualBox itself, and not Vagrant. The issue seems to be addressed in ticket number 20636 titled, “VBoxHeadless does not run in macOS Monterey 12.0.1 => fixed in SVN/next maintenance.” And according to a comment by the user “klaus”:
The latest 6.1 test build has the fix, but the usual "not notarized" caveat applies which is documented there, with the "disable SIP" workaround.
UPDATE: Fixed in VirtualBox version 6.1.30; the version 6.1 changelog explicitly references ticket number 20636:
VBoxHeadless: Fixed crash when running on macOS Monterey (bug #20636)
This is a know issue with VirtualBox. They are currently working on it. It is not a Vagrant issue.
You can test this by going to VirtualBox and running the machine which works fine unless you try headless
or detached
state.