hyperledger/fabric · error

orderer is required, but no ordering endpoint or endorser cl

Error message

orderer is required, but no ordering endpoint or endorser client supplied

What it means

When an orderer is required (invoke or query-with-orderer), InitCmdFactory needs either an explicit ordering endpoint (-o / --orderer) or an endorser client from which to discover the channel's orderer endpoints. If both are absent, it refuses to proceed with this error.

Source

Thrown at internal/peer/chaincode/common.go:412

		if len(endorserClients) == 0 {
			return nil, errors.New("no endorser clients retrieved - this might indicate a bug")
		}
	}
	certificate, err := common.GetClientCertificateFnc()
	if err != nil {
		return nil, errors.WithMessage(err, "error getting client certificate")
	}

	signer, err := common.GetDefaultSignerFnc()
	if err != nil {
		return nil, errors.WithMessage(err, "error getting default signer")
	}

	var broadcastClient common.BroadcastClient
	if isOrdererRequired {
		if len(common.OrderingEndpoint) == 0 {
			if len(endorserClients) == 0 {
				return nil, errors.New("orderer is required, but no ordering endpoint or endorser client supplied")
			}
			endorserClient := endorserClients[0]

			orderingEndpoints, err := common.GetOrdererEndpointOfChainFnc(channelID, signer, endorserClient, cryptoProvider)
			if err != nil {
				return nil, errors.WithMessagef(err, "error getting channel (%s) orderer endpoint", channelID)
			}
			if len(orderingEndpoints) == 0 {
				return nil, errors.Errorf("no orderer endpoints retrieved for channel %s, pass orderer endpoint with -o flag instead", channelID)
			}
			logger.Infof("Retrieved channel (%s) orderer endpoint: %s", channelID, orderingEndpoints[0])
			// override viper env
			viper.Set("orderer.address", orderingEndpoints[0])
		}

		broadcastClient, err = common.GetBroadcastClientFnc()
		if err != nil {
			return nil, errors.WithMessage(err, "error getting broadcast client")

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Pass the orderer explicitly: add `-o orderer.example.com:7050` (plus --tls and --cafile if TLS is enabled)
  2. Set the ORDERER_ADDRESS environment variable (and ORDERER_TLS_* vars as needed)
  3. Ensure at least one --peerAddresses is supplied so an endorser client can be used for orderer-endpoint discovery

Example fix

// before
peer chaincode invoke -C mychannel -n mycc -c '{...}'
// after
peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /path/ca.pem -C mychannel -n mycc -c '{...}'
Defensive patterns

Strategy: validation

Validate before calling

if os.Getenv("ORDERER_ADDRESS") == "" && orderingEndpointFlag == "" {
    return fmt.Errorf("orderer required: pass -o <host:port> or set ORDERER_ADDRESS")
}

Prevention

When it happens

Trigger: Running `peer chaincode invoke` (isOrdererRequired=true) without the `-o/--orderer` flag, with common.OrderingEndpoint empty, and no endorser clients available (e.g. isEndorserRequired=false or no peers configured).

Common situations: Forgetting the -o flag in scripts; running query paths that skip endorser setup; CI environments missing ORDERER_ADDRESS env var; copying a query command and removing peer flags.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/77552998319c86ae. Report an issue: GitHub.