hyperledger/fabric · error

peer '%s' is defined in the channel config but doesn't have

Error message

peer '%s' is defined in the channel config but doesn't have associated peer config

What it means

This error comes from validatePeerConnectionParameters when a peer is listed in the channel's configuration (networkConfig.Channels[channelID].Peers) with endorsing rights, but there is no corresponding entry in the local peer config (networkConfig.Peers). The CLI cannot build a peer address/TLS cert list because the peer's URL and TLS CA certs are unknown.

Source

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

	}

	return nil
}

func validatePeerConnectionParameters(cmdName string) error {
	if connectionProfile != common.UndefinedParamValue {
		networkConfig, err := common.GetConfig(connectionProfile)
		if err != nil {
			return err
		}
		if len(networkConfig.Channels[channelID].Peers) != 0 {
			peerAddresses = []string{}
			tlsRootCertFiles = []string{}
			for peer, peerChannelConfig := range networkConfig.Channels[channelID].Peers {
				if peerChannelConfig.EndorsingPeer {
					peerConfig, ok := networkConfig.Peers[peer]
					if !ok {
						return errors.Errorf("peer '%s' is defined in the channel config but doesn't have associated peer config", peer)
					}
					peerAddresses = append(peerAddresses, peerConfig.URL)
					tlsRootCertFiles = append(tlsRootCertFiles, peerConfig.TLSCACerts.Path)
				}
			}
		}
	}

	// currently only support multiple peer addresses for invoke
	multiplePeersAllowed := map[string]bool{
		"invoke": true,
	}
	_, ok := multiplePeersAllowed[cmdName]
	if !ok && len(peerAddresses) > 1 {
		return errors.Errorf("'%s' command can only be executed against one peer. received %d", cmdName, len(peerAddresses))
	}

	if len(tlsRootCertFiles) > len(peerAddresses) {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Add a matching entry for the peer under the 'peers' section of your connection profile / local config
  2. Pass --peerAddresses (and --tlsRootCertFiles) explicitly so the CLI doesn't derive peers from channel config
  3. Compare the peer keys in channels.<channelID>.peers vs peers and fix the name mismatch
  4. Refresh the connection profile after any channel config reconfiguration

Example fix

# before (channels.mychannel.peers lists peer0.org2 but peers section lacks it)
# after
channels:
  mychannel:
    peers:
      peer0.org2.example.com:
        endorsingPeer: true
peers:
  peer0.org2.example.com:
    url: grpcs://peer0.org2.example.com:7051
    tlsCACerts:
      path: /path/to/org2-ca.crt
Defensive patterns

Strategy: validation

Validate before calling

# connection profile check: every endorsing peer under channels.<c>.peers must exist under peers
for p in $(yq e '.channels.mychannel.peers | keys | .[]' cp.yaml); do
  yq e ".peers.$p" cp.yaml >/dev/null || { echo "peer $p missing from peers section"; exit 1; }
done

Prevention

When it happens

Trigger: Running an invoke/endorsement command where channel config references a peer that lacks a matching section in the local core.yaml / connection profile peers map, and --peerAddresses was not supplied explicitly.

Common situations: Stale or incomplete connection profile missing the peer under the top-level 'peers' section, channel config updated on the orderer to add a peer before local config was updated, typo between the peer name in channels.<channel>.peers and peers.<name>.

Related errors


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