{"record":{"id":"d7edc2a7e85e457b","repo":"netbirdio/netbird","slug":"active-profile-not-found-please-run-netbird-prof","errorCode":null,"errorMessage":"active profile not found, please run 'netbird profile create' first","messagePattern":"active profile not found, please run 'netbird profile create' first","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/login.go","lineNumber":249,"sourceCode":"\treturn nil\n}\n\nfunc getActiveProfile(ctx context.Context, pm *profilemanager.ProfileManager, profileName string, username string) (*profilemanager.Profile, error) {\n\t// switch profile if provided\n\n\tif profileName != \"\" {\n\t\tif err := switchProfileOnDaemon(ctx, pm, profileName, username); err != nil {\n\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","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/login.go#L231-L267","documentation":"The profile store loaded successfully but GetActiveProfile returned nil: no profile exists or none is marked active. This is the empty-state error for a fresh installation or after all profiles were deleted, and the message directs the user to create one. It is a usage/precondition error, not a system failure.","triggerScenarios":"First run of 'netbird login'/'netbird up' on a machine with no profile store; the previously active profile was deleted without switching to another; the profile store was reset (config dir wiped).","commonSituations":"New VM or container provisioned and the automation calls login before creating a profile; User cleaned ~/.netbird to 'reset' the client and then ran a status command; Migrated host where the config dir was not carried over","solutions":["Run 'netbird profile create' (or any 'netbird login' flow that creates the default profile) and retry","Or pass --profile-name pointing at an existing profile from 'netbird profile list' so a profile gets selected instead of relying on the active pointer","If the store was wiped intentionally, re-register the machine with 'netbird up --setup-key <key>' which recreates the default profile"],"exampleFix":"# before\n$ netbird login\nError: active profile not found, please run 'netbird profile create' first\n\n# after\n$ netbird profile create --name work\n$ netbird login","handlingStrategy":"validation","validationCode":"// Precondition check: an active profile must exist before login flows\npm := profilemanager.NewProfileManager()\nprofiles, err := pm.GetProfiles()\nif err != nil {\n    return err\n}\nactive := false\nfor _, p := range profiles {\n    if p.IsActive {\n        active = true\n    }\n}\nif !active && len(profiles) == 0 {\n    return fmt.Errorf(\"no profiles: run 'netbird profile create' first\")\n}","typeGuard":"// hasActiveProfile narrows the store state before calling getActiveProfile\nfunc hasActiveProfile(profiles []profilemanager.Profile) bool {\n    for _, p := range profiles {\n        if p.IsActive {\n            return true\n        }\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Provisioning scripts should create the profile (or use --setup-key) as the first step, before any status command","After deleting a profile, immediately switch to another one instead of leaving no active profile","Treat this message as a usage prompt: it is expected on first run, not a bug"],"tags":["profile","precondition","cli","netbird","first-run"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}