theforeman/foreman · error · Foreman::Exception

Unable to connect to libvirt due to: %s. Please make sure yo

Error message

Unable to connect to libvirt due to: %s. Please make sure your libvirt compute resource is reachable and that you have appropriate access permissions.

What it means

Error "Unable to connect to libvirt due to: %s. Please make sure your libvirt compute resource is reachable and that you have appropriate access permissions." thrown in theforeman/foreman.

Source

Thrown at app/models/compute_resources/foreman/model/libvirt.rb:277

          conn.terminate if conn.respond_to?(:terminate)
          Thread.current[name] = nil
        end
      end
    end

    def disconnect
      self.class.terminate_connection(url)
    end

    def image_exists?(uuid)
      client.volumes.get(uuid) != nil
    end

    protected

    def libvirt_connection_error
      msg = N_('Unable to connect to libvirt due to: %s. Please make sure your libvirt compute resource is reachable and that you have appropriate access permissions.')
      raise Foreman::Exception.new(msg, errors.full_messages.join(', '))
    end

    def client
      tries ||= 3
      key = "libvirt_connection_#{url}"
      Thread.current[key] ||= begin
        conn = ::Fog::Compute.new(:provider => "Libvirt", :libvirt_uri => url)
        logger.debug { "Created libvirt connection #{conn.object_id}: #{url}" }
        conn
      end
    rescue ::Libvirt::RetrieveError
      logger.debug { "Libvirt connection failed, trying again" }
      Thread.current[key] = nil
      retry unless (tries -= 1).zero?
    end

    def vm_instance_defaults
      super.merge(

View on GitHub (pinned to 6b05625475)

When it happens

Trigger: Thrown at app/models/compute_resources/foreman/model/libvirt.rb:277 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of theforeman/foreman@6b05625475 (2026-08-23). Data as JSON: /api/errors/900c5f509e4df0fd. Report an issue: GitHub.