netbirdio/netbird · error
connection to daemon closed unexpectedly
Error message
connection to daemon closed unexpectedly
What it means
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().
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
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at client/cmd/expose.go:282 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16).
Data as JSON: /api/errors/4427b34ac7900e8d.
Report an issue: GitHub.
Appendix: source
Thrown at client/cmd/expose.go:282
}
if r.PortAutoAssigned && exposeExternalPort != 0 {
cmd.Printf("\n Note: requested port %d was reassigned\n", exposeExternalPort)
}
cmd.Println()
cmd.Println("Press Ctrl+C to stop exposing.")
}
func waitForExposeEvents(cmd *cobra.Command, ctx context.Context, stream proto.DaemonService_ExposeServiceClient) error {
for {
_, err := stream.Recv()
if err != nil {
if ctx.Err() != nil {
cmd.Println("\nService stopped.")
//nolint:nilerr
return nil
}
if errors.Is(err, io.EOF) {
return fmt.Errorf("connection to daemon closed unexpectedly")
}
return fmt.Errorf("stream error: %w", err)
}
}
}
View on GitHub (pinned to 93e97f4bf1)