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.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF