{"record":{"id":"36e81de840adc5c3","repo":"kubernetes/kops","slug":"error-listening-on-q-w","errorCode":null,"errorMessage":"error listening on %q: %w","messagePattern":"error listening on %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bootstrap/challenge_server.go","lineNumber":138,"sourceCode":"\nfunc (s *ChallengeListener) Stop() {\n\ts.grpcServer.Stop()\n}\n\nfunc (s *ChallengeListener) Endpoint() string {\n\treturn s.endpoint\n}\n\nfunc (s *ChallengeServer) NewListener(ctx context.Context, listen string) (*ChallengeListener, error) {\n\tvar opts []grpc.ServerOption\n\n\topts = append(opts, grpc.Creds(credentials.NewTLS(s.tlsConfig)))\n\tgrpcServer := grpc.NewServer(opts...)\n\tpb.RegisterCallbackServiceServer(grpcServer, s)\n\n\tlis, err := net.Listen(\"tcp\", listen)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listening on %q: %w\", listen, err)\n\t}\n\n\tgrpcListener := &ChallengeListener{\n\t\tserver:     s,\n\t\tgrpcServer: grpcServer,\n\t\tendpoint:   lis.Addr().String(),\n\t}\n\n\tgo func() {\n\t\tklog.Infof(\"starting node-challenge listener on %v\", lis.Addr())\n\t\tif err := grpcServer.Serve(lis); err != nil {\n\t\t\tlis.Close()\n\n\t\t\tklog.Warningf(\"error serving GRPC: %v\", err)\n\t\t}\n\t}()\n\n\treturn grpcListener, nil","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/bootstrap/challenge_server.go#L120-L156","documentation":"NewListener calls net.Listen(\"tcp\", listen) to bind the address the challenge gRPC server will serve on; any bind failure is wrapped with this message including the address. Typical causes are the port already in use or lacking permission to bind the address.","triggerScenarios":"Calling NewListener/Run when the configured listen address's port is occupied by another process, the address is invalid/unassigned on the host, or binding a privileged port without privileges.","commonSituations":"Two kops-controller replicas on the same host/port; a stale process holding the port after an upgrade; listen address typo or host networking misconfiguration; container not granted the port (non-root binding <1024).","solutions":["Check what holds the port (ss -ltnp / lsof -i :<port>) and stop it or change the listen port","Correct the listen address in the configuration to a valid local IP/host","Run with sufficient privileges or use a non-privileged port (>1024)","Ensure only one instance of the controller binds the port"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"if ln, err := net.Listen(\"tcp\", listen); err != nil {\n\treturn fmt.Errorf(\"address %q unavailable before starting server: %w\", listen, err)\n} else { ln.Close() }","typeGuard":null,"tryCatchPattern":"lis, err := s.NewListener(listen)\nif err != nil {\n\tif strings.Contains(err.Error(), \"error listening\") && errors.Is(err, syscall.EADDRINUSE) {\n\t\t// free the port or pick an alternate port and retry\n\t}\n\treturn err\n}","preventionTips":["Check port occupancy before starting the controller","Configure a single replica per host/port","Avoid privileged ports or grant the binary CAP_NET_BIND_SERVICE"],"tags":["network","listen","port-in-use","grpc","server"],"backgroundTag":"address-already-in-use","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"}