{"record":{"id":"bd94f53894c3ae07","repo":"netbirdio/netbird","slug":"install-service-w","errorCode":null,"errorMessage":"install service: %w","messagePattern":"install service: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/service_installer.go","lineNumber":156,"sourceCode":"\t\tif err := loadAndApplyServiceParams(cmd); err != nil {\n\t\t\tcmd.PrintErrf(\"Warning: failed to load saved service params: %v\\n\", err)\n\t\t}\n\n\t\tsvcConfig, err := createServiceConfigForInstall()\n\t\tif err != nil {\n\t\t\treturn 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), svcConfig)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := s.Install(); err != nil {\n\t\t\treturn fmt.Errorf(\"install service: %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\tcmd.Println(\"NetBird service has been installed\")\n\t\treturn nil\n\t},\n}\n\nvar uninstallCmd = &cobra.Command{\n\tUse:   \"uninstall\",\n\tShort: \"uninstalls NetBird service from system\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tif err := setupServiceCommand(cmd); err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/service_installer.go#L138-L174","documentation":"kardianos/service Install() failed while registering the NetBird daemon with the system service manager (systemd unit, launchd plist, or Windows SCM). The %w chain keeps the manager-specific reason, which on Linux usually includes systemctl output.","triggerScenarios":"Running `netbird service install` without root/admin; a netbird unit or Windows service with the same --service name already exists; systemd not reachable (container, chroot); installing into a read-only /etc or /Library/LaunchDaemons.","commonSituations":"Second install without an intervening uninstall; running install inside docker/podman where systemd is not PID 1; Windows UAC elevation declined so the SCM refuses registration.","solutions":["Re-run with elevation: sudo netbird service install (or an elevated PowerShell on Windows)","Remove the previous registration first: sudo netbird service uninstall, or inspect the leftover unit with systemctl status netbird","If in a container, run with systemd as PID 1 or install on the host instead","Read the wrapped manager error for the exact systemctl/SCM message before retrying"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if os.Geteuid() != 0 {\n\treturn errors.New(\"netbird service install requires root/admin\")\n}\nif _, err := os.Stat(filepath.Join(\"/etc/systemd/system\", serviceName+\".service\")); err == nil {\n\treturn errors.New(\"service already installed; run netbird service uninstall first\")\n}","typeGuard":null,"tryCatchPattern":"if err := s.Install(); err != nil {\n\treturn fmt.Errorf(\"install service: %w\", err)\n}\n// Read the manager-specific text under the wrap; privilege failures never succeed on retry without elevation.","preventionTips":["Run install only from an elevated shell","Uninstall before reinstalling the same service name","Do not install inside containers lacking systemd"],"tags":["service","installer","privileges","systemd","go"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}