{"record":{"id":"f265a5b42b221188","repo":"hashicorp/nomad","slug":"service-registration-check-failed-w","errorCode":null,"errorMessage":"service registration check failed - %w","messagePattern":"service registration check failed - %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/windows_service_install.go","lineNumber":195,"sourceCode":"\tc.Ui.Output(fmt.Sprintf(\"  Nomad configuration directory: %s\", opts.configDir))\n\tc.Ui.Output(fmt.Sprintf(\"  Nomad agent data directory: %s\", opts.configDir))\n\n\t// Now let's install that service\n\tif err := c.serviceInstall(m, opts); err != nil {\n\t\treturn fmt.Errorf(\"service install failed - %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (c *WindowsServiceInstallCommand) serviceInstall(m winsvc.WindowsServiceManager, opts *windowsInstallOpts) error {\n\tvar err error\n\tvar srvc winsvc.WindowsService\n\tcmd := fmt.Sprintf(\"%s agent -config %s\", opts.binaryPath, opts.configDir)\n\n\texists, err := m.IsServiceRegistered(winsvc.WINDOWS_SERVICE_NAME)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"service registration check failed - %w\", err)\n\t}\n\n\t// If the service already exists, open it and update. Otherwise\n\t// create a new service.\n\tif exists {\n\t\tsrvc, err = m.GetService(winsvc.WINDOWS_SERVICE_NAME)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to get existing service - %w\", err)\n\t\t}\n\t\tdefer srvc.Close()\n\t\tif err := srvc.Configure(winsvc.WindowsServiceConfiguration{\n\t\t\tStartType:      winsvc.StartAutomatic,\n\t\t\tDisplayName:    winsvc.WINDOWS_SERVICE_DISPLAY_NAME,\n\t\t\tDescription:    winsvc.WINDOWS_SERVICE_DESCRIPTION,\n\t\t\tBinaryPathName: cmd,\n\t\t}); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to configure service - %w\", err)\n\t\t}","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/windows_service_install.go#L177-L213","documentation":"Wraps a failure from `IsServiceRegistered(WINDOWS_SERVICE_NAME)` on the Windows service manager. Before creating or updating the service, install queries the SCM for whether 'Nomad' exists; if that query itself errors, install aborts with this message.","triggerScenarios":"Opening the SCM database or querying service 'Nomad' fails — typically ERROR_ACCESS_DENIED when not elevated, or SCM RPC failure.","commonSituations":"Running the install command in a non-elevated shell; broken Windows management instrumentation/SCM after updates; remote-registry restrictions.","solutions":["Re-run the command from an elevated (Run as Administrator) shell","Verify the SCM is healthy: `sc query nomad` from an admin prompt","Reboot the host if SCM/RPC is in a bad state after updates","Check antivirus/security software blocking SCM queries"],"exampleFix":"// before\nPS> nomad windows install\n// after\nPS (admin)> nomad windows install","handlingStrategy":"try-catch","validationCode":"out, err := exec.Command(\"sc.exe\", \"query\", \"nomad\").CombinedOutput()\nif err != nil && !strings.Contains(string(out), \"1060\") {\n\tlog.Fatalf(\"SCM query failed unexpectedly: %v\\n%s\", err, out)\n}","typeGuard":null,"tryCatchPattern":"exists, err := m.IsServiceRegistered(winsvc.WINDOWS_SERVICE_NAME)\nif err != nil {\n\tif errors.Is(err, windows.ERROR_ACCESS_DENIED) { /* elevate and retry */ }\n\treturn fmt.Errorf(\"service registration check failed - %w\", err)\n}","preventionTips":["Always install from an elevated shell","Confirm SCM health with `sc query nomad` beforehand","Reboot after Windows updates if SCM RPC errors appear"],"tags":["windows","service-control-manager","permissions"],"backgroundTag":"access-denied-service-manager","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"}