{"record":{"id":"c7f4f48a0b84624c","repo":"ahmetb/kubectx","slug":"failed-to-start-readonly-proxy-w","errorCode":null,"errorMessage":"failed to start readonly proxy: %w","messagePattern":"failed to start readonly proxy: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubectx/readonly_shell.go","lineNumber":70,"sourceCode":"\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to create temp kubeconfig file: %w\", err)\n\t\t\t}\n\t\t\torigPath := origFile.Name()\n\n\t\t\tif _, err := origFile.Write(data); err != nil {\n\t\t\t\torigFile.Close()\n\t\t\t\tos.Remove(origPath)\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to write temp kubeconfig: %w\", err)\n\t\t\t}\n\t\t\torigFile.Close()\n\n\t\t\t// Start the readonly proxy.\n\t\t\tp, err := proxy.Start(proxy.Config{\n\t\t\t\tKubeconfigPath: origPath,\n\t\t\t\tContextName:    op.Target,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tos.Remove(origPath)\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to start readonly proxy: %w\", err)\n\t\t\t}\n\n\t\t\t// Rewrite kubeconfig to point to the proxy.\n\t\t\trewritten, err := proxy.RewriteKubeconfig(data, p.Addr())\n\t\t\tif err != nil {\n\t\t\t\tp.Shutdown(context.Background())\n\t\t\t\tos.Remove(origPath)\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to rewrite kubeconfig: %w\", err)\n\t\t\t}\n\n\t\t\ttime.Sleep(10 * time.Millisecond)\n\n\t\t\tcleanup := func() {\n\t\t\t\tp.Shutdown(context.Background())\n\t\t\t\tos.Remove(origPath)\n\t\t\t}\n\t\t\treturn rewritten, cleanup, nil\n\t\t},","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/ahmetb/kubectx/blob/12ad6fb22e8c546ee2b54e7de38aa51c906832f7/cmd/kubectx/readonly_shell.go#L52-L88","documentation":"Wrapper error in transformKubeconfig: proxy.Start failed to launch the read-only TLS proxy for the target context (bind failure on the local address, cert/TLS setup problem, or bad kubeconfig data). The temp kubeconfig is cleaned up and the shell start aborts; cause wrapped with %w.","triggerScenarios":"Thrown at cmd/kubectx/readonly_shell.go:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped cause — often a port bind conflict or TLS/cert issue","Verify the cluster server URL and certificates in the kubeconfig are valid","Retry starting the readonly shell"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"12ad6fb22e8c546ee2b54e7de38aa51c906832f7","analyzedAt":"2026-09-02T12:23:10.107Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}