hashicorp/nomad · error
could not get existing service to stop - %w
Error message
could not get existing service to stop - %w
What it means
Returned by performInstall when WindowsServiceManager.GetService fails to open the already-registered Nomad service prior to stopping it for reinstall. The service exists but its handle could not be obtained.
Source
Thrown at command/windows_service_install.go:142
}
c.Ui.Info("Successfully installed nomad Windows service")
return 0
}
func (c *WindowsServiceInstallCommand) performInstall(m winsvc.WindowsServiceManager, opts *windowsInstallOpts) error {
// Check if the nomad service has already been
// registered. If so the service needs to be
// stopped before proceeding with the install.
exists, err := m.IsServiceRegistered(winsvc.WINDOWS_SERVICE_NAME)
if err != nil {
return fmt.Errorf("unable to check for existing service - %w", err)
}
if exists {
nmdSvc, err := m.GetService(winsvc.WINDOWS_SERVICE_NAME)
if err != nil {
return fmt.Errorf("could not get existing service to stop - %w", err)
}
// If the service is running and the reinstall
// option was not set, return an error
running, err := nmdSvc.IsRunning()
if err != nil {
return fmt.Errorf("unable to determine service state - %w", err)
}
if running && !opts.reinstall {
return fmt.Errorf("service is already running. Please run the\ncommand again with -reinstall to stop the service and install.")
}
if running {
c.Ui.Output(" Stopping existing nomad service")
if err := nmdSvc.Stop(); err != nil {
return fmt.Errorf("unable to stop existing service - %w", err)
}
}View on GitHub (pinned to 482b49bf1a)
Solutions
- Re-run from an elevated prompt with sufficient SCM rights
- Check the service wasn't deleted concurrently
- Inspect the wrapped OS error for access-denied details
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at command/windows_service_install.go:142 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/e894c3ce3ab93a88.
Report an issue: GitHub.