netbirdio/netbird · error

connect to daemon: %v

Error message

connect to daemon: %v

What it means

`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).

Source

Thrown at client/cmd/logout.go:29

	"github.com/netbirdio/netbird/client/proto"
)

var logoutCmd = &cobra.Command{
	Use:     "deregister",
	Aliases: []string{"logout"},
	Short:   "Deregister from the NetBird management service and delete this peer",
	Long:    "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.",
	RunE: func(cmd *cobra.Command, args []string) error {
		SetFlagsFromEnvVars(rootCmd)

		cmd.SetOut(cmd.OutOrStdout())

		ctx, cancel := context.WithTimeout(cmd.Context(), time.Second*15)
		defer cancel()

		conn, err := DialClientGRPCServer(ctx, daemonAddr)
		if err != nil {
			return fmt.Errorf("connect to daemon: %v", err)
		}
		defer conn.Close()

		daemonClient := proto.NewDaemonServiceClient(conn)

		req := &proto.LogoutRequest{}

		if profileName != "" {
			req.ProfileName = &profileName

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

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Verify the daemon is up: `systemctl status netbird` (Linux) / `sc query netbird` (Windows), then start it if stopped
  2. Confirm the socket exists: `ls -l /var/run/netbird.sock` and re-run with the matching `--daemon-addr` (or unset NB_DAEMON_ADDR)
  3. Check daemon logs (`journalctl -u netbird`) for a crash loop and restart the service
  4. If the socket is absent but the service claims running, reinstall/restart the service so it recreates the listener
Defensive patterns

Strategy: validation

Validate before calling

// Run before invoking the CLI programmatically
if _, err := os.Stat("/var/run/netbird.sock"); err != nil {
    log.Fatal("netbird daemon socket missing; start the netbird service first")
}

Type guard

func daemonReachable(addr string) bool {
    if strings.HasPrefix(addr, "npipe://") {
        return true // named pipe: check via dial on Windows
    }
    u, err := url.Parse(addr)
    if err != nil || u.Path == "" {
        return false
    }
    _, err = os.Stat(u.Path)
    return err == nil
}

Try / catch

conn, err := DialClientGRPCServer(ctx, daemonAddr)
if err != nil {
    if errors.Is(err, context.DeadlineExceeded) {
        return fmt.Errorf("daemon did not answer in time; is the netbird service running?")
    }
    return fmt.Errorf("connect to daemon: %w", err)
}

Prevention

When it happens

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

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

Related errors


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