{"record":{"id":"b7e2dba482b53093","repo":"juanfont/headscale","slug":"connecting-to-headscale-w","errorCode":null,"errorMessage":"connecting to headscale: %w","messagePattern":"connecting to headscale: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/headscale/cli/utils.go","lineNumber":114,"sourceCode":"\t}\n\n\tapp, err := hscontrol.NewHeadscale(cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"creating new headscale: %w\", err)\n\t}\n\n\treturn app, nil\n}\n\n// clientRunE wraps a [cobra.Command.RunE] func, injecting a ready API client\n// and a context whose timeout/cancel the wrapper owns.\nfunc clientRunE(\n\tfn func(ctx context.Context, client *clientv1.ClientWithResponses, cmd *cobra.Command, args []string) error,\n) func(*cobra.Command, []string) error {\n\treturn func(cmd *cobra.Command, args []string) error {\n\t\tctx, client, cancel, err := newHeadscaleCLIWithConfig()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"connecting to headscale: %w\", err)\n\t\t}\n\t\tdefer cancel()\n\n\t\treturn fn(ctx, client, cmd, args)\n\t}\n}\n\n// withClient runs fn with an API client. For commands that branch on a flag\n// before talking to the server, where clientRunE's whole-RunE wrapping does\n// not fit.\nfunc withClient(\n\tfn func(ctx context.Context, client *clientv1.ClientWithResponses) error,\n) error {\n\tctx, client, cancel, err := newHeadscaleCLIWithConfig()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"connecting to headscale: %w\", err)\n\t}\n\tdefer cancel()","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/headscale/cli/utils.go#L96-L132","documentation":"Error \"connecting to headscale: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at cmd/headscale/cli/utils.go:114 when the library encounters an invalid state.","commonSituations":"The CLI could not connect to the headscale gRPC server. Verify the server is running and the socket path or address in the CLI config is correct.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (connecting to headscale); retry the operation after fixing the input, configuration, or environment."],"exampleFix":"Inspect the wrapped error for the underlying cause and correct the failing condition (connecting to headscale); retry the operation after fixing the input, configuration, or environment.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}