{"record":{"id":"dd508e2e13368073","repo":"netbirdio/netbird","slug":"switch-profile-v-dd508e","errorCode":null,"errorMessage":"switch profile: %v","messagePattern":"switch profile: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/up.go","lineNumber":134,"sourceCode":"\tctx := internal.CtxInitState(cmd.Context())\n\n\tif hostName != \"\" {\n\t\t// nolint\n\t\tctx = context.WithValue(ctx, system.DeviceNameCtxKey, hostName)\n\t}\n\n\tpm := profilemanager.NewProfileManager()\n\n\tusername, err := user.Current()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get current user: %v\", err)\n\t}\n\n\tvar profileSwitched bool\n\t// switch profile if provided\n\tif profileName != \"\" {\n\t\tif err := switchOrCreateProfile(cmd.Context(), pm, profileName, username.Username); err != nil {\n\t\t\treturn fmt.Errorf(\"switch profile: %v\", err)\n\t\t}\n\t\tprofileSwitched = true\n\t}\n\n\tactiveProf, err := pm.GetActiveProfile()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get active profile: %v\", err)\n\t}\n\n\tif foregroundMode {\n\t\treturn runInForegroundMode(ctx, cmd, activeProf)\n\t}\n\treturn runInDaemonMode(ctx, cmd, pm, activeProf, profileSwitched)\n}\n\n// switchOrCreateProfile switches the active profile to the one identified by\n// handle, creating it first when it does not exist yet. This restores the\n// pre-0.73 behaviour where `netbird up --profile <name>` auto-creates a","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/up.go#L116-L152","documentation":"Thrown by upFunc (client/cmd/up.go:134) when switchOrCreateProfile fails after 'netbird up --profile <name>'. That helper resolves the profile handle to an ID via the daemon (switchProfile), auto-creating it when the daemon reports NotFound (createProfile), then calls pm.SwitchProfile locally. The wrap aggregates any of those steps failing - most commonly the daemon dial inside the auto-create path.","triggerScenarios":"'netbird up --profile x' while the daemon is not running (the inner createProfile dial fails with the 'failed to connect to daemon' error); the daemon RPC to resolve the handle returns an error other than NotFound; or the local SwitchProfile(resolvedID) fails on a corrupted profile store.","commonSituations":"Fresh machines where the service is installed but not started; profile store files under ~/.config/netbird with wrong ownership after running netbird once under sudo and once as the user.","solutions":["Start the daemon first: 'netbird service install' then 'netbird service start' (or systemctl start netbird)","Retry 'netbird up --profile <name>' once the daemon socket answers ('netbird status --check live' passes)","Verify the profile exists or can be created: 'netbird profiles list'","Check ownership/permissions of the profile store directory if SwitchProfile is the failing step"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure the daemon answers before switching profiles\nif err := runHealthCheckLive(); err != nil {\n    log.Fatal(\"start the daemon first: netbird service install && netbird service start\")\n}","typeGuard":null,"tryCatchPattern":"if err := switchOrCreateProfile(ctx, pm, profileName, username.Username); err != nil {\n    if st, ok := gstatus.FromError(errors.Unwrap(err)); ok && st.Code() == codes.Unavailable {\n        // daemon down: guide user to start service, safe to retry afterwards\n        return startDaemonAndRetry()\n    }\n    return fmt.Errorf(\"switch profile: %w\", err)\n}","preventionTips":["Confirm 'netbird status --check live' passes before 'up --profile'","Keep profile store ownership consistent (avoid mixing sudo and plain user runs)","Rerun the command after daemon restarts - the auto-create path tolerates races by design"],"tags":["cli","daemon","profiles","netbird"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}