{"record":{"id":"a267f71213953dd8","repo":"netbirdio/netbird","slug":"switch-profile-on-daemon-v","errorCode":null,"errorMessage":"switch profile on daemon: %v","messagePattern":"switch profile on daemon: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/login.go","lineNumber":257,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"switch profile: %v\", err)\n\t\t}\n\t}\n\n\tactiveProf, err := pm.GetActiveProfile()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get active profile: %v\", err)\n\t}\n\n\tif activeProf == nil {\n\t\treturn nil, fmt.Errorf(\"active profile not found, please run 'netbird profile create' first\")\n\t}\n\treturn activeProf, nil\n}\n\nfunc switchProfileOnDaemon(ctx context.Context, pm *profilemanager.ProfileManager, handle string, username string) error {\n\tresolvedID, err := switchProfile(ctx, handle, username)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"switch profile on daemon: %v\", err)\n\t}\n\n\tif err := pm.SwitchProfile(resolvedID); err != nil {\n\t\treturn fmt.Errorf(\"switch profile: %v\", err)\n\t}\n\n\tconn, err := DialClientGRPCServer(ctx, daemonAddr)\n\tif err != nil {\n\t\tlog.Errorf(\"failed to connect to service CLI interface %v\", err)\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\n\tclient := proto.NewDaemonServiceClient(conn)\n\n\tstatus, err := client.Status(ctx, &proto.StatusRequest{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to get daemon status: %v\", err)","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/login.go#L239-L275","documentation":"Wraps switchProfile(ctx, handle, username), the helper that dials the daemon and issues the SwitchProfile RPC to resolve a name/ID-prefix into a concrete profile ID. This error fires when the dial itself fails (daemon not running: error 227) or when the RPC returns an error (profile not found for the name+username filter, ambiguous unique-ID prefix: error 228).","triggerScenarios":"--profile-name value that matches no profile; a short ID prefix that matches several profiles; daemon not installed/started; daemon socket present but stale after an unclean stop.","commonSituations":"Profile renamed or deleted in another terminal after the user copied its name; Daemon crashed or was stopped as part of troubleshooting; Windows named pipe not available because the service is stopped","solutions":["Confirm the daemon is running ('netbird service status', start it if not)","List profiles with 'netbird profile list' and pass the exact name or the full ID (avoid short prefixes)","If names collide across users, also pass the matching --username","Check the inner error text: 'failed to connect to daemon' means daemon-side, 'switch profile failed' means resolution-side"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Resolve the handle locally first; only hit the daemon when it exists\nprofiles, _ := pm.GetProfiles()\nfor _, p := range profiles {\n    if p.Name == handle || strings.HasPrefix(string(p.ID), handle) {\n        return nil // resolvable, proceed\n    }\n}\nreturn fmt.Errorf(\"profile handle %q unknown; run 'netbird profile list'\", handle)","typeGuard":null,"tryCatchPattern":"if err := switchProfileOnDaemon(ctx, pm, handle, username); err != nil {\n    if status.Code(errors.Unwrap(err)) == codes.NotFound {\n        // wrong name or ambiguous prefix: surface profile list to the user\n    }\n    return err\n}","preventionTips":["Use full profile IDs in scripts to avoid ambiguous-prefix resolution failures","Confirm the daemon service is running before profile operations","Include --username whenever multiple users may share profile names on a host"],"tags":["profile","daemon","grpc","cli","netbird"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}