hashicorp/nomad · error
unable to check for existing service - %w
Error message
unable to check for existing service - %w
What it means
performUninstall wraps the error from the service manager's IsServiceRegistered(WINDOWS_SERVICE_NAME), the first step of uninstalling the Nomad Windows service. It means the uninstaller could not determine whether the service exists, so it aborts rather than blindly proceeding. This is not a 'service not found' case — that returns nil.
Source
Thrown at command/windows_service_uninstall.go:92
c.Ui.Error(fmt.Sprintf("Could not connect to Windows service manager - %s", err))
return 1
}
defer m.Close()
if err := c.performUninstall(m); err != nil {
c.Ui.Error(fmt.Sprintf("Service uninstall failed: %s", err))
return 1
}
c.Ui.Info("Successfully uninstalled nomad Windows service")
return 0
}
func (c *WindowsServiceUninstallCommand) performUninstall(m winsvc.WindowsServiceManager) error {
// Check that the nomad service is currently registered
exists, err := m.IsServiceRegistered(winsvc.WINDOWS_SERVICE_NAME)
if err != nil {
return fmt.Errorf("unable to check for existing service - %w", err)
}
if !exists {
return nil
}
// Grab the service and ensure the service is stopped
srvc, err := m.GetService(winsvc.WINDOWS_SERVICE_NAME)
if err != nil {
return fmt.Errorf("could not get existing service - %w", err)
}
defer srvc.Close()
if err := srvc.Stop(); err != nil {
return fmt.Errorf("unable to stop service - %w", err)
}
// Remove the service from the event logView on GitHub (pinned to 482b49bf1a)
Solutions
- Run the uninstall command from an elevated (Administrator) prompt
- Inspect the wrapped error for a specific Windows error code (e.g. access denied)
- Check that the Service Control Manager is healthy (sc query works)
- Retry after fixing SCM permissions or machine policy
Example fix
# before C:\> nomad windows service uninstall unable to check for existing service - access denied # after (elevated) C:\> nomad windows service uninstall
Defensive patterns
Strategy: try-catch
Try / catch
out, err := exec.Command("sc", "query", "nomad").CombinedOutput()
if err != nil {
// if access denied, re-run elevated before uninstalling
_ = out
} Prevention
- Always run service install/uninstall from an elevated prompt
- Verify SCM access with `sc query` first
- Avoid running under restricted service accounts or policy-limited shells
When it happens
Trigger: The Windows SCM (Service Control Manager) call underlying IsServiceRegistered fails — e.g. the uninstaller is not elevated, SCM is unreachable, or the manager handle is invalid while performUninstall runs.
Common situations: Running `nomad windows service uninstall` from a non-elevated shell; SCM access denied by policy; corrupted service manager state.
Related errors
- could not get existing service - %w
- service registration check failed - %w
- unable to create service - %w
- cannot create copy - %s
- unable to stop service - %w
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/9ce3babc3b7e0d4c.
Report an issue: GitHub.