{"record":{"id":"dd3e97461830b813","repo":"netbirdio/netbird","slug":"uninstall-service-w","errorCode":null,"errorMessage":"uninstall service: %w","messagePattern":"uninstall service: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/service_installer.go","lineNumber":190,"sourceCode":"\t\tif err := setupServiceCommand(cmd); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tcfg, err := newSVCConfig()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"create service config: %w\", err)\n\t\t}\n\n\t\tctx, cancel := context.WithCancel(cmd.Context())\n\t\tdefer cancel()\n\n\t\ts, err := newSVC(newProgram(ctx, cancel), cfg)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := s.Uninstall(); err != nil {\n\t\t\treturn fmt.Errorf(\"uninstall service: %w\", err)\n\t\t}\n\n\t\tif runtime.GOOS == \"linux\" {\n\t\t\tif err := cleanupSystemdNetworkd(); err != nil {\n\t\t\t\tlog.Warnf(\"failed to cleanup systemd-networkd configuration: %v\", err)\n\t\t\t}\n\t\t}\n\n\t\tcmd.Println(\"NetBird service has been uninstalled\")\n\t\treturn nil\n\t},\n}\n\nvar reconfigureCmd = &cobra.Command{\n\tUse:   \"reconfigure\",\n\tShort: \"reconfigures NetBird service with new settings\",\n\tLong: `Reconfigures the NetBird service with new settings without manual uninstall/install.\nThis command will temporarily stop the service, update its configuration, and restart it if it was running.`,","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/service_installer.go#L172-L208","documentation":"kardianos/service Uninstall() failed while deregistering the NetBird service. The underlying manager error is preserved; typical causes are missing privileges, the service not existing, or the manager refusing while it is running.","triggerScenarios":"`netbird service uninstall` without root/admin; uninstalling when no unit/service is registered; Windows SCM has the service marked for deletion but still referenced; a manager that requires the service stopped first.","commonSituations":"Running uninstall twice; uninstalling from a non-elevated shell; uninstalling immediately after stop on Windows before the SCM completes the delete.","solutions":["Run elevated: sudo netbird service uninstall","Stop the service first: sudo netbird service stop (or systemctl stop netbird)","If the service is already gone, treat not-installed as success instead of retrying","On Windows, reopen the shell or reboot if the SCM reports deletion pending"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if os.Geteuid() != 0 {\n\treturn errors.New(\"netbird service uninstall requires root/admin\")\n}","typeGuard":"func isNotInstalled(err error) bool {\n\treturn err != nil && strings.Contains(strings.ToLower(err.Error()), \"not installed\")\n}","tryCatchPattern":"if err := s.Uninstall(); err != nil {\n\tif isNotInstalled(err) {\n\t\treturn nil // already gone: treat as success\n\t}\n\treturn fmt.Errorf(\"uninstall service: %w\", err)\n}","preventionTips":["Stop the service before uninstalling","Treat not-installed as success in automation scripts","Always uninstall from an elevated shell"],"tags":["service","uninstaller","privileges","systemd","go"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}