Creating and destroying virtual machines in Vagrant left and right might get us in trouble. If we reuse the domain name, Vagrant will fail to create it again. Here is how to use virsh if Vagrant won’t help anymore.
This is how the error look like:
$ vagrant up Bringing machine default up with libvirt provider… ==> default: Checking if box fedora/30-cloud-base version30.20190425.0 is up to date… Name `backend_default` of domain about to create is already taken. Please try to run `vagrant up` command again.
The domain (a virtual machine in virtualization slang) is taken. Sometimes this happens because we already have a default project in the directory of the same name. But other times, it’s not as simple, and Vagrant won’t cooperate.
vagrant destroy doesn’t help, we can use
virsh to tackle the problem.
First, we can try
virth destroy, which immediate ungraceful shutdown:
$ virsh destroy backend_default error: Failed to destroy domain backend_default error: Requested operation is not valid: domain is not running
But in my case, the domain was not running, so
virsh destroy would not work.
Second option is to use
virsh undefine, which removes the configuration:
$ virsh undefine backend_default
Removing the configuration altogether did the trick for me. Vagrant wouldn’t see a domain of this name anymore and successfully create the new one.
← BUY THE PRE-RELEASE
I am writing a complete guide on web application deployment. Ruby with Puma, Python with Gunicorn, NGINX, PostgreSQL, Redis, networking, processes, systemd, backups, and all your usual suspects. Final release soon!