{"record":{"id":"4427b34ac7900e8d","repo":"netbirdio/netbird","slug":"connection-to-daemon-closed-unexpectedly","errorCode":null,"errorMessage":"connection to daemon closed unexpectedly","messagePattern":"connection to daemon closed unexpectedly","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/expose.go","lineNumber":282,"sourceCode":"\t}\n\tif r.PortAutoAssigned && exposeExternalPort != 0 {\n\t\tcmd.Printf(\"\\n  Note: requested port %d was reassigned\\n\", exposeExternalPort)\n\t}\n\tcmd.Println()\n\tcmd.Println(\"Press Ctrl+C to stop exposing.\")\n}\n\nfunc waitForExposeEvents(cmd *cobra.Command, ctx context.Context, stream proto.DaemonService_ExposeServiceClient) error {\n\tfor {\n\t\t_, err := stream.Recv()\n\t\tif err != nil {\n\t\t\tif ctx.Err() != nil {\n\t\t\t\tcmd.Println(\"\\nService stopped.\")\n\t\t\t\t//nolint:nilerr\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tif errors.Is(err, io.EOF) {\n\t\t\t\treturn fmt.Errorf(\"connection to daemon closed unexpectedly\")\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"stream error: %w\", err)\n\t\t}\n\t}\n}\n","sourceCodeStart":264,"sourceCodeEnd":288,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/expose.go#L264-L288","documentation":"The gRPC expose event stream returned io.EOF before the context was cancelled, meaning the daemon shut down its side of the stream (crash, restart, or internal error) while the CLI was still waiting for events. Distinguished from a user-initiated stop, which is detected via ctx.Err().","triggerScenarios":"Thrown at client/cmd/expose.go:282 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check whether the netbird daemon is still running (systemctl status netbird or netbird service status) and inspect its logs for the reason it closed the stream","Restart the daemon with 'netbird service restart' and re-run the expose command","If it recurs, capture daemon debug logs (--log-level debug) around the time of the disconnect to find the internal error that ended the stream"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","contentChangedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}