netbirdio/netbird · error

switch profile: %v

Error message

switch profile: %v

What it means

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.

Source

Thrown at client/cmd/up.go:134

	ctx := internal.CtxInitState(cmd.Context())

	if hostName != "" {
		// nolint
		ctx = context.WithValue(ctx, system.DeviceNameCtxKey, hostName)
	}

	pm := profilemanager.NewProfileManager()

	username, err := user.Current()
	if err != nil {
		return fmt.Errorf("get current user: %v", err)
	}

	var profileSwitched bool
	// switch profile if provided
	if profileName != "" {
		if err := switchOrCreateProfile(cmd.Context(), pm, profileName, username.Username); err != nil {
			return fmt.Errorf("switch profile: %v", err)
		}
		profileSwitched = true
	}

	activeProf, err := pm.GetActiveProfile()
	if err != nil {
		return fmt.Errorf("get active profile: %v", err)
	}

	if foregroundMode {
		return runInForegroundMode(ctx, cmd, activeProf)
	}
	return runInDaemonMode(ctx, cmd, pm, activeProf, profileSwitched)
}

// switchOrCreateProfile switches the active profile to the one identified by
// handle, creating it first when it does not exist yet. This restores the
// pre-0.73 behaviour where `netbird up --profile <name>` auto-creates a

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Start the daemon first: 'netbird service install' then 'netbird service start' (or systemctl start netbird)
  2. Retry 'netbird up --profile <name>' once the daemon socket answers ('netbird status --check live' passes)
  3. Verify the profile exists or can be created: 'netbird profiles list'
  4. Check ownership/permissions of the profile store directory if SwitchProfile is the failing step
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the daemon answers before switching profiles
if err := runHealthCheckLive(); err != nil {
    log.Fatal("start the daemon first: netbird service install && netbird service start")
}

Try / catch

if err := switchOrCreateProfile(ctx, pm, profileName, username.Username); err != nil {
    if st, ok := gstatus.FromError(errors.Unwrap(err)); ok && st.Code() == codes.Unavailable {
        // daemon down: guide user to start service, safe to retry afterwards
        return startDaemonAndRetry()
    }
    return fmt.Errorf("switch profile: %w", err)
}

Prevention

When it happens

Trigger: '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.

Common situations: 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.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/dd508e2e13368073. Report an issue: GitHub.