netbirdio/netbird · error

stream error

Error message

stream error: %w

What it means

Generic wrap around any non-EOF, non-context-cancellation error from stream.Recv() on the expose event stream: transport failures, RPC status errors, or socket problems while the CLI listens for daemon events.

Solutions

  1. Read the wrapped error to distinguish a daemon restart from a socket/transport failure
  2. Verify the daemon Unix socket/named pipe still exists and the daemon process is alive
  3. Re-run 'netbird expose' once the daemon is healthy again
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at client/cmd/expose.go:284 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/0e588147e1f1c65d. Report an issue: GitHub.

Appendix: source

Thrown at client/cmd/expose.go:284

		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)