{"record":{"id":"ea407e8c3ed00ec0","repo":"netbirdio/netbird","slug":"connect-to-daemon-w","errorCode":null,"errorMessage":"connect to daemon: %w","messagePattern":"connect to daemon: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/expose.go","lineNumber":175,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.Root().SilenceUsage = true\n\n\tctx, cancel := context.WithCancel(cmd.Context())\n\tdefer cancel()\n\n\tsigCh := make(chan os.Signal, 1)\n\tsignal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)\n\tgo func() {\n\t\t<-sigCh\n\t\tcancel()\n\t}()\n\n\tconn, err := DialClientGRPCServer(ctx, daemonAddr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"connect to daemon: %w\", err)\n\t}\n\tdefer func() {\n\t\tif err := conn.Close(); err != nil {\n\t\t\tlog.Debugf(\"failed to close daemon connection: %v\", err)\n\t\t}\n\t}()\n\n\tclient := proto.NewDaemonServiceClient(conn)\n\n\tprotocol, err := toExposeProtocol(exposeProtocol)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq := &proto.ExposeServiceRequest{\n\t\tPort:       uint32(port),\n\t\tProtocol:   protocol,\n\t\tPin:        exposePin,","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/expose.go#L157-L193","documentation":"DialClientGRPCServer could not establish a gRPC connection to the daemon. It calls grpc.DialContext with WithBlock under a 10-second timeout, targeting whatever --daemon-addr resolves to via daddr.DialTarget (unix socket, npipe on Windows, or TCP), so this error means 'no daemon answered within 10s'. The underlying dial error is wrapped with %w.","triggerScenarios":"The netbird service is not installed or not started; the daemon crashed; --daemon-addr / NB_DAEMON_ADDR points at a socket or host the daemon is not serving; the unix socket file was deleted (e.g. tmpfs cleanup of /var/run); permission denied on the socket; a SIGINT/SIGTERM arrived before or during the dial and canceled the context.","commonSituations":"Fresh machine before `netbird service install`/start; systemd unit in failed state; containers or minimal VMs with only the CLI; running as a user without access to the daemon socket; boot race where the command runs before the service.","solutions":["Start or install the daemon: `sudo systemctl start netbird` (Windows: `sc start netbird`; if missing: `netbird service install`) and re-run `netbird expose`","Sanity-check with `netbird status` — if that also fails, the daemon is down; read its logs (journalctl -u netbird / client.log) to find why","If --daemon-addr or NB_DAEMON_ADDR is set, verify it exactly matches the daemon's serve address or unset it to use the default","If the socket file is missing while the service claims active, restart the service so it recreates it"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# fail fast if the daemon is not there before invoking expose\nsystemctl is-active --quiet netbird || echo \"netbird service not active; start it first\"\nnetbird status >/dev/null 2>&1 || echo \"daemon not answering on its socket\"","typeGuard":null,"tryCatchPattern":"conn, err := DialClientGRPCServer(ctx, daemonAddr)\nif err != nil {\n\tif ctx.Err() == context.Canceled {\n\t\treturn fmt.Errorf(\"interrupted before connecting: %w\", err)\n\t}\n\t// 10s blocking dial timed out: daemon absent or wrong address; fix that, do not loop blindly\n\treturn fmt.Errorf(\"connect to daemon (is the netbird service running at %s?): %w\", daemonAddr, err)\n}","preventionTips":["Ensure `netbird service install` was run and the service is active before any expose/debug command","Keep --daemon-addr/NB_DAEMON_ADDR consistent with the daemon's actual serve address","Treat repeated dial timeouts as 'daemon down', not a slow network — check the service, then retry","In boot scripts, wait for the socket to appear (systemd `After=netbird.service`) instead of racing it"],"tags":["grpc","daemon","connection","ipc","netbird-cli"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}