Bobcares

Virsh failed to connect to the hypervisor – Here is how we fix it

by | Jan 25, 2020

Are you receiving the error failed to connect to the hypervisor while running virsh?

The reason for this can vary from no connection driver to missing permissions.

At Bobcares, we often get a request to fix virsh errors, as a part of our Server Management Services.

Today, let’s see why this error occurs and will also see how our Support Engineers fix it.

 

Virsh error failed to connect to the hypervisor

Virsh is a command-line tool used for managing guest VMs and the hypervisor. But connecting to the server while running virsh can sometimes end up in errors.

And one such error message is ‘error: failed to connect to the hypervisor’. There can be many possible reasons for this error to occur.

Let’s have a look at a few of them.

 

Causes and fixes for the virsh error

Our customers often approach us with errors while running virsh. Let’s see a few instances where our Support Engineers fixed this error.

 

1. Connection driver unavailable

While running a virsh command, a user got the following error message.

error: no connection driver available for No connection for URI <uri>
error: failed to connect to the hypervisor

The error message clearly specifies that there is no connection driver for the URI. So our Support Engineers check the configure output. And it should appear as,

configure: Drivers
configure:
configure: <driver>: yes

We also check the development libraries and configure the sources if needed.

 

2. Unable to read CA certificate

Another customer got a different error message while running the virsh command. And the error message was,

error: Cannot read CA certificate '/etc/pki/CA/cacert.pem': No such file or directory
error: failed to connect to the hypervisor

This can be due to two possible reasons – incorrect URI or connection configuration error.

So our Support Engineers check the specified URI and correct it if needed. If the error is with the configuration, then it needs a detailed look. And our Experts check it and fix the error.

 

3. Permission denied error

Similarly, another error message while running a virsh command is,

error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied
error: failed to connect to the hypervisor

Here we check if the same error shows up while running the command as a root user. If the non-root user is only getting this error then the error is with the configuration.

To fix this our Support Engineers edit the /etc/libvirt/libvirt.conf file. And we add the permissions, which appears as,

#unix_sock_group = "libvirt"
#unix_sock_ro_perms = "0777"
#unix_sock_rw_perms = "0770"

Later we restart the libvirtd service. And this fixed the error.

 

4. Connection refused while running virsh

While trying to connect to a host system the virsh command fails with the error message.

error: failed to connect to the hypervisor
error: unable to connect to the server at 'host:16509': Connection refused

The error message indicates that the libvirt is not listening on the TCP port. So our Support Engineers check the /etc/libvirt/libvirtd.conf file.

And we ensure that the TCP port is listening. We also check if the libvirt configuration is correct or not.

For this, we open the /etc/sysconfig/libvirtd file. Here we uncomment the line,

virsh failed to connect to the hypervisor.

Later on, restarting the libvirt the error resolves.

 

5. Authentication failure while connecting to the hypervisor

In addition, some users get auth failed error while connecting to the server using virsh. Here the error message appears as

error: failed to connect to the hypervisor
error: authentication failed: authentication failed

This can be either due to incorrect credentials or else due to improper configuration.

So our Support Engineers check the /etc/libvirt/libvirtd.conf file. And ensure that the auth_tcp value is set to sasl. And we edit the /etc/sasl2/libvirt.conf file and add the following

mech_list: digest-md5
sasldb_path: /etc/libvirt/passwd.db

We also ensure to check the cyrus-sasl-md5 package. Later we restart the libvirt service and set user name and password for SASL.

 

[Need assistance in fixing virsh errors? – We can help you.]

 

Conclusion

So far we saw the various reasons for the virsh error failed to connect to the hypervisor. This can be due to driver connection, permissions, etc. Today, we saw how our Support Engineers fix this error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.