This is an article resolving on how to handle the error specified in the title of this article. The error itself is “Failed to connect socket to ‘/var/run/libvirt/libvirt-sock’: Connection refused”. The error happened after resolving the problem exist in this article titled ‘How to Solve Error Failed to acquire pid file ‘/var/run/libvirtd.pid’: Resource temporarily unavailable’ in this link .
The error is triggered also in the webvirt image which is presented in a different message but basically stated a connection refused error as shown below :
As shown in the above image, the error shown is :
"Unable to connect to server at '127.0.0.1: 16409' : Connection refused.
The main problem is the actual connection has already been successfully carried out but suddenly the error occurred. Both in the webpage displaying the libvirt management dashboard and also in the connection process using qemu as shown below :
root@hostname:~# virsh -c qemu:///system error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused root@hostname:~#
In order to grasp further the cause of the error generated shown above, check the log file exist in ‘/var/log/libvirt/qemu/virtual-server-name.log’ in the following :
root@hostname:~# tail -f /var/log/libvirt/qemu/djpk-cacti.log Note: only modules from the same build can be loaded. Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-curl.so Note: only modules from the same build can be loaded. Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-rbd.so Note: only modules from the same build can be loaded. Failed to initialize module: /usr/lib/x86_64-linux-gnu/qemu/block-dmg.so Note: only modules from the same build can be loaded. char device redirected to /dev/pts/6 (label charserial0) ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy failed to initialize KVM: Device or resource busy
The main hint is shown in the several last lines of log as shown below :
ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy failed to initialize KVM: Device or resource busy
The error specified that the KVM or Kernel-based Virtual Machine’s resource is busy. As expected of the error given, it means that the KVM resource is already used by another virtualization technology or platform. In the case of this situation, after checking further, Virtualbox is actually active, so it is blocking libvirt from accessing KVM’s resource. So, to solve this matter, the action taken is by turning off and exiting from Virtualbox. Another cause of error can also be the culprit for the generated error especially on the configuration entry listed in /etc/libvirt/libvirt.conf.
One thought on “How to Solve Error Message : Failed to connect socket to ‘/var/run/libvirt/libvirt-sock’: Connection refused”