Resolving the "Requested operation is not valid: network 'default' is not active" Error in Libvirt
When using virtualization tools like Libvirt, you may encounter an error preventing you from starting your virtual machine. This post will walk you through diagnosing and fixing the issue where the "network 'default' is not active," causing your virtual machine startup to fail.
Here’s a breakdown of the issue and steps to resolve it.
The Problem
The error typically looks like this:
Error starting domain: Requested operation is not valid: network 'default' is not active Traceback (most recent call last): File "/usr/share/virt-manager/virtManager/asyncjob.py", line 72, in cb_wrapper callback(asyncjob, *args, **kwargs) File "/usr/share/virt-manager/virtManager/asyncjob.py", line 108, in tmpcb callback(*args, **kwargs) File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn ret = fn(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/share/virt-manager/virtManager/object/domain.py", line 1402, in startup self._backend.create() File "/usr/lib/python3.12/site-packages/libvirt.py", line 1379, in create raise libvirtError('virDomainCreate() failed') libvirt.libvirtError: Requested operation is not valid: network 'default' is not active
This error message indicates that the virtual machine is trying to connect to a network that isn't active, specifically the default
network.
The Solution
To fix this, follow these steps:
1. Check the Status of Networks
First, verify if the default
network is active:
virsh net-list --all
You should see output similar to:
Name State Autostart Persistent ------------------------------------------ default inactive yes yes
If the State
of the default
network is listed as "inactive," that's the problem.
2. Start the Network
You can start the network with:
sudo virsh net-start default
This should return:
Network default started
3. Enable Auto-Start for the Network (Optional)
To prevent this issue from happening again after reboot, enable the network to start automatically:
sudo virsh net-autostart default
This command should confirm:
Network default marked as autostarted
4. Start Your Virtual Machine
Now, you should be able to start your virtual machine without any issues:
virsh start <vm-name>
Replace <vm-name>
with the name of your virtual machine.