{"record":{"id":"dca323d491afd60f","repo":"kubernetes/kops","slug":"listening-on-s-w","errorCode":null,"errorMessage":"listening on %s: %w","messagePattern":"listening on (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"channels/pkg/cmd/readiness.go","lineNumber":67,"sourceCode":"}\n\nfunc serveReadinessOnAddr(ctx context.Context, addr string) (*applyChannelReadiness, error) {\n\treadiness := &applyChannelReadiness{}\n\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(\"/readyz\", func(w http.ResponseWriter, _ *http.Request) {\n\t\tif readiness.ready.Load() {\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\t_, _ = w.Write([]byte(\"ok\\n\"))\n\t\t} else {\n\t\t\tw.WriteHeader(http.StatusServiceUnavailable)\n\t\t\t_, _ = w.Write([]byte(\"apply iterations are failing\\n\"))\n\t\t}\n\t})\n\n\tlistener, err := net.Listen(\"tcp\", addr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"listening on %s: %w\", addr, err)\n\t}\n\treadiness.addr = listener.Addr().String()\n\n\tserver := &http.Server{\n\t\tHandler:           mux,\n\t\tReadHeaderTimeout: 5 * time.Second,\n\t}\n\n\tgo func() {\n\t\t<-ctx.Done()\n\t\t_ = server.Close()\n\t}()\n\tgo func() {\n\t\tif err := server.Serve(listener); err != nil && !errors.Is(err, http.ErrServerClosed) {\n\t\t\tklog.Fatalf(\"kops-channels readiness server stopped: %v\", err)\n\t\t}\n\t}()\n\treturn readiness, nil","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/channels/pkg/cmd/readiness.go#L49-L85","documentation":"serveReadinessOnAddr creates a TCP listener for the readiness /readyz endpoint; this wraps net.Listen failing on the requested address, almost always because the port is already in use or the node lacks permission to bind (privileged port).","triggerScenarios":"Thrown at channels/pkg/cmd/readiness.go:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check what is already listening on the address (e.g. ss -ltnp) and free the port","Configure the readiness probe to use a different, unused port","If binding a port <1024, run with adequate privileges or choose a higher port"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}