{"record":{"id":"70ee0b6e1a30915d","repo":"hashicorp/nomad","slug":"service-is-already-running-please-run-the-command","errorCode":null,"errorMessage":"service is already running. Please run the\ncommand again with -reinstall to stop the service and install.","messagePattern":"service is already running\\. Please run the\ncommand again with -reinstall to stop the service and install\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/windows_service_install.go","lineNumber":152,"sourceCode":"\texists, err := m.IsServiceRegistered(winsvc.WINDOWS_SERVICE_NAME)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to check for existing service - %w\", err)\n\t}\n\n\tif exists {\n\t\tnmdSvc, err := m.GetService(winsvc.WINDOWS_SERVICE_NAME)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not get existing service to stop - %w\", err)\n\t\t}\n\n\t\t// If the service is running and the reinstall\n\t\t// option was not set, return an error\n\t\trunning, err := nmdSvc.IsRunning()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to determine service state - %w\", err)\n\t\t}\n\t\tif running && !opts.reinstall {\n\t\t\treturn fmt.Errorf(\"service is already running. Please run the\\ncommand again with -reinstall to stop the service and install.\")\n\t\t}\n\n\t\tif running {\n\t\t\tc.Ui.Output(\"  Stopping existing nomad service\")\n\t\t\tif err := nmdSvc.Stop(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"unable to stop existing service - %w\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Install the nomad binary into the system\n\tif err = c.binaryInstall(opts); err != nil {\n\t\treturn fmt.Errorf(\"binary install failed - %w\", err)\n\t}\n\n\tc.Ui.Output(fmt.Sprintf(\"  Nomad binary installed to: %s\", opts.binaryPath))\n\n\t// Create a configuration directory and add","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/windows_service_install.go#L134-L170","documentation":"Deliberate guard in performInstall: the existing Nomad Windows service is currently running and -reinstall was not supplied, so the install refuses to stop/replace a live service; the operator must opt in.","triggerScenarios":"Thrown at command/windows_service_install.go:152 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run the install command with -reinstall to stop and replace the running service","Or stop the service manually (sc stop / services.msc) before installing","Schedule the reinstall during a maintenance window to avoid agent downtime"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}