{"record":{"id":"277009061bff6245","repo":"netbirdio/netbird","slug":"uninstall-existing-service-w","errorCode":null,"errorMessage":"uninstall existing service: %w","messagePattern":"uninstall existing service: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/service_installer.go","lineNumber":245,"sourceCode":"\n\t\tctx, cancel := context.WithCancel(cmd.Context())\n\t\tdefer cancel()\n\n\t\ts, err := newSVC(newProgram(ctx, cancel), svcConfig)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"create service: %w\", err)\n\t\t}\n\n\t\tif wasRunning {\n\t\t\tcmd.Println(\"Stopping NetBird service...\")\n\t\t\tif err := s.Stop(); err != nil {\n\t\t\t\tcmd.Printf(\"Warning: failed to stop service: %v\\n\", err)\n\t\t\t}\n\t\t}\n\n\t\tcmd.Println(\"Removing existing service configuration...\")\n\t\tif err := s.Uninstall(); err != nil {\n\t\t\treturn fmt.Errorf(\"uninstall existing service: %w\", err)\n\t\t}\n\n\t\tcmd.Println(\"Installing service with new configuration...\")\n\t\tif err := s.Install(); err != nil {\n\t\t\treturn fmt.Errorf(\"install service with new config: %w\", err)\n\t\t}\n\n\t\tif err := saveServiceParams(currentServiceParams()); err != nil {\n\t\t\tcmd.PrintErrf(\"Warning: failed to save service params: %v\\n\", err)\n\t\t}\n\n\t\tif wasRunning {\n\t\t\tcmd.Println(\"Starting NetBird service...\")\n\t\t\tif err := s.Start(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"start service after reconfigure: %w\", err)\n\t\t\t}\n\t\t\tcmd.Println(\"NetBird service has been reconfigured and started\")\n\t\t} else {","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/service_installer.go#L227-L263","documentation":"Mid-reconfigure, uninstalling the current registration failed. By this point the service may already have been stopped, and the wrapped kardianos error says why deregistration failed (privileges, missing unit, manager state).","triggerScenarios":"reconfigure without elevation; service.json exists but the unit file was already removed manually (rm /etc/systemd/system/netbird.service); Windows SCM deletion pending from a previous operation.","commonSituations":"Manual cleanup with rm instead of netbird service uninstall between reconfigures; losing elevation mid-script.","solutions":["Run with sudo/elevation","If the registration is already gone, do a fresh sudo netbird service install instead of reconfigure","Remove leftover unit files by hand only after the manager reports not-installed","Inspect the wrapped manager error before retrying"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := os.Stat(filepath.Join(\"/etc/systemd/system\", serviceName+\".service\")); os.IsNotExist(err) {\n\t// registration already gone; a plain install will succeed where reconfigure cannot\n}","typeGuard":null,"tryCatchPattern":"if err := s.Uninstall(); err != nil {\n\treturn fmt.Errorf(\"uninstall existing service: %w\", err)\n}\n// If the wrapped error says not-installed, switch to a fresh install instead of retrying reconfigure.","preventionTips":["Clean up registrations with netbird service uninstall, never rm","Run reconfigure elevated end to end"],"tags":["service","reconfigure","privileges","systemd","go"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}