{"record":{"id":"590881f345a91f8d","repo":"hyperledger/fabric","slug":"cannot-obtain-orderer-endpoint-empty-endorser-lis","errorCode":null,"errorMessage":"cannot obtain orderer endpoint, empty endorser list","messagePattern":"cannot obtain orderer endpoint, empty endorser list","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/client_connections.go","lineNumber":209,"sourceCode":"\t\treturn errors.WithMessage(err, \"failed to retrieve client cerificate\")\n\t}\n\n\tc.Certificate = certificate\n\n\treturn nil\n}\n\nfunc (c *ClientConnections) setOrdererClient() error {\n\toe := viper.GetString(\"orderer.address\")\n\tif oe == \"\" {\n\t\t// if we're here we didn't get an orderer endpoint from the command line\n\t\t// so we'll attempt to get one from cscc - bless it\n\t\tif c.Signer == nil {\n\t\t\treturn errors.New(\"cannot obtain orderer endpoint, no signer was configured\")\n\t\t}\n\n\t\tif len(c.EndorserClients) == 0 {\n\t\t\treturn errors.New(\"cannot obtain orderer endpoint, empty endorser list\")\n\t\t}\n\n\t\torderingEndpoints, err := common.GetOrdererEndpointOfChainFnc(channelID, c.Signer, c.EndorserClients[0], c.CryptoProvider)\n\t\tif err != nil {\n\t\t\treturn errors.WithMessagef(err, \"error getting channel (%s) orderer endpoint\", channelID)\n\t\t}\n\t\tif len(orderingEndpoints) == 0 {\n\t\t\treturn errors.Errorf(\"no orderer endpoints retrieved for channel %s, pass orderer endpoint with -o flag instead\", channelID)\n\t\t}\n\n\t\tlogger.Infof(\"Retrieved channel (%s) orderer endpoint: %s\", channelID, orderingEndpoints[0])\n\t\t// override viper env\n\t\tviper.Set(\"orderer.address\", orderingEndpoints[0])\n\t}\n\n\tbroadcastClient, err := common.GetBroadcastClient()\n\tif err != nil {\n\t\treturn errors.WithMessage(err, \"failed to retrieve broadcast client\")","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/client_connections.go#L191-L227","documentation":"In setOrdererClient, when no orderer address was supplied, the peer attempts to discover one by querying the cscc (configuration system chaincode) via an endorser client. If the client has zero endorser clients configured, there is no peer to ask for the orderer endpoint, so this error is thrown.","triggerScenarios":"Running a lifecycle chaincode command (approve/commit/checkcommitreadiness etc.) without an orderer address (-o / --orderer) and without any peer endorser addresses (--peerAddresses), so NewClientConnections builds a ClientConnections with an empty EndorserClients slice.","commonSituations":"CLI invocations missing both -o and --peerAddresses flags; scripts that set only the orderer flag but no peers; test harnesses constructing the client struct programmatically without calling the code that appends endorser clients.","solutions":["Add at least one --peerAddresses flag (with --tlsRootCertFiles if TLS is on) so an endorser client is created.","Supply -o/--orderer so the cscc lookup path is skipped entirely.","Check that --peerAddresses parsing/viper keys are not being overridden by environment variables like CORE_PEER_ADDRESS.","If constructing ClientConnections in code, populate EndorserClients before calling NewClientConnections."],"exampleFix":"// before\npeer lifecycle chaincode commit -C mychannel --name mycc --version 1.0\n// after\npeer lifecycle chaincode commit -C mychannel --name mycc --version 1.0 \\\n  --peerAddresses peer0.org1.example.com:7051 \\\n  --tlsRootCertFiles /path/org1.pem \\\n  -o orderer.example.com:7050","handlingStrategy":"validation","validationCode":"if !strings.Contains(os.Getenv(\"CORE_PEER_ADDRESS\"), \"peer\") && ordererFlag == \"\" {\n    // ensure at least one --peerAddresses or -o is provided\n}\n// CLI: require flags before running\n// if orderer == \"\" && len(peerAddresses) == 0 { return errors.New(\"provide -o or --peerAddresses\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass -o/--orderer on lifecycle chaincode commands.","Or supply --peerAddresses (and --tlsRootCertFiles when TLS is enabled).","Script the full flag set once and reuse it across approve/commit."],"tags":["hyperledger-fabric","peer-cli","orderer-discovery","cli-flags"],"backgroundTag":"empty-endorser-list","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}