{"record":{"id":"63bd0dd4468e33b9","repo":"netbirdio/netbird","slug":"connect-to-daemon-v","errorCode":null,"errorMessage":"connect to daemon: %v","messagePattern":"connect to daemon: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/logout.go","lineNumber":29,"sourceCode":"\t\"github.com/netbirdio/netbird/client/proto\"\n)\n\nvar logoutCmd = &cobra.Command{\n\tUse:     \"deregister\",\n\tAliases: []string{\"logout\"},\n\tShort:   \"Deregister from the NetBird management service and delete this peer\",\n\tLong:    \"This command will deregister the current peer from the NetBird management service and all associated configuration. Use with caution as this will remove the peer from the network.\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tSetFlagsFromEnvVars(rootCmd)\n\n\t\tcmd.SetOut(cmd.OutOrStdout())\n\n\t\tctx, cancel := context.WithTimeout(cmd.Context(), time.Second*15)\n\t\tdefer cancel()\n\n\t\tconn, err := DialClientGRPCServer(ctx, daemonAddr)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"connect to daemon: %v\", err)\n\t\t}\n\t\tdefer conn.Close()\n\n\t\tdaemonClient := proto.NewDaemonServiceClient(conn)\n\n\t\treq := &proto.LogoutRequest{}\n\n\t\tif profileName != \"\" {\n\t\t\treq.ProfileName = &profileName\n\n\t\t\tcurrUser, err := user.Current()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"get current user: %v\", err)\n\t\t\t}\n\t\t\tusername := currUser.Username\n\t\t\treq.Username = &username\n\t\t}\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/logout.go#L11-L47","documentation":"`netbird logout` (deregister) could not open a gRPC connection to the NetBird daemon. DialClientGRPCServer (client/cmd/root.go:271) dials the daemon address with grpc.WithBlock() and a 10s timeout inside the command's 15s ctx; any dial failure (socket absent, permission denied, timeout) is wrapped as 'connect to daemon: %v'. The daemon is a separate privileged service; the CLI only talks to it over unix socket (Linux/macOS) or named pipe (Windows).","triggerScenarios":"Daemon service not running; /var/run/netbird.sock missing or stale; --daemon-addr or NB_DAEMON_ADDR pointing at the wrong target; npipe://netbird unavailable on Windows; dial exceeding the 10s WithBlock timeout; socket owned by root and CLI run as a user without access.","commonSituations":"Fresh install where `netbird service install/start` was never run; daemon crashed or was stopped; running the CLI inside a container/namespace that cannot see the host socket; upgrading changed the socket path; custom tcp:// daemon-addr from an old install.","solutions":["Verify the daemon is up: `systemctl status netbird` (Linux) / `sc query netbird` (Windows), then start it if stopped","Confirm the socket exists: `ls -l /var/run/netbird.sock` and re-run with the matching `--daemon-addr` (or unset NB_DAEMON_ADDR)","Check daemon logs (`journalctl -u netbird`) for a crash loop and restart the service","If the socket is absent but the service claims running, reinstall/restart the service so it recreates the listener"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Run before invoking the CLI programmatically\nif _, err := os.Stat(\"/var/run/netbird.sock\"); err != nil {\n    log.Fatal(\"netbird daemon socket missing; start the netbird service first\")\n}","typeGuard":"func daemonReachable(addr string) bool {\n    if strings.HasPrefix(addr, \"npipe://\") {\n        return true // named pipe: check via dial on Windows\n    }\n    u, err := url.Parse(addr)\n    if err != nil || u.Path == \"\" {\n        return false\n    }\n    _, err = os.Stat(u.Path)\n    return err == nil\n}","tryCatchPattern":"conn, err := DialClientGRPCServer(ctx, daemonAddr)\nif err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        return fmt.Errorf(\"daemon did not answer in time; is the netbird service running?\")\n    }\n    return fmt.Errorf(\"connect to daemon: %w\", err)\n}","preventionTips":["Install and start the netbird service before using CLI commands that need the daemon","Pin --daemon-addr/NB_DAEMON_ADDR to the same address the service was configured with","In automation, probe the socket's existence before running netbird commands"],"tags":["grpc","daemon","connection","cli","unix-socket"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}