hyperledger/fabric · critical

peer.address isn't set

Error message

peer.address isn't set

What it means

getLocalAddress reads peer.address from configuration (viper, so env override CORE_PEER_ADDRESS also applies) to determine the address:port this peer advertises. If it is empty, load() fails with this error and the peer cannot start, because it must know its own reachable address. This is a required-configuration check.

Source

Thrown at core/peer/config.go:341

	c.MetricsProvider = viper.GetString("metrics.provider")
	c.StatsdNetwork = viper.GetString("metrics.statsd.network")
	c.StatsdAaddress = viper.GetString("metrics.statsd.address")
	c.StatsdWriteInterval = viper.GetDuration("metrics.statsd.writeInterval")
	c.StatsdPrefix = viper.GetString("metrics.statsd.prefix")

	c.DockerCert = config.GetPath("vm.docker.tls.cert.file")
	c.DockerKey = config.GetPath("vm.docker.tls.key.file")
	c.DockerCA = config.GetPath("vm.docker.tls.ca.file")

	return nil
}

// getLocalAddress returns the address:port the local peer is operating on.  Affected by env:peer.addressAutoDetect
func getLocalAddress() (string, error) {
	peerAddress := viper.GetString("peer.address")
	if peerAddress == "" {
		return "", errors.New("peer.address isn't set")
	}
	host, port, err := net.SplitHostPort(peerAddress)
	if err != nil {
		return "", errors.Errorf("peer.address isn't in host:port format: %s", peerAddress)
	}

	localIP, err := getLocalIP()
	if err != nil {
		peerLogger.Errorf("local IP address not auto-detectable: %s", err)
		return "", err
	}
	autoDetectedIPAndPort := net.JoinHostPort(localIP, port)
	peerLogger.Info("Auto-detected peer address:", autoDetectedIPAndPort)
	// If host is the IPv4 address "0.0.0.0" or the IPv6 address "::",
	// then fallback to auto-detected address
	if ip := net.ParseIP(host); ip != nil && ip.IsUnspecified() {
		peerLogger.Info("Host is", host, ", falling back to auto-detected address:", autoDetectedIPAndPort)
		return autoDetectedIPAndPort, nil

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Set CORE_PEER_ADDRESS=peer0.org1.example.com:7051 (host:port) in the peer's environment and restart.
  2. Alternatively set peer.address in core.yaml to a host:port value.
  3. If peer.addressAutoDetect is desired, still ensure a sane default address is configured for the platform.
  4. Inspect the container's effective env (docker inspect / kubectl exec env) to confirm the variable is not empty, then fix the compose/Helm values.

Example fix

# before (docker-compose env)
CORE_PEER_ADDRESS=
# after
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
Defensive patterns

Strategy: validation

Validate before calling

addr := os.Getenv("CORE_PEER_ADDRESS")
if addr == "" {
    addr = viper.GetString("peer.address")
}
if addr == "" {
    return fmt.Errorf("peer.address (or CORE_PEER_ADDRESS) must be set as host:port")
}
if _, _, err := net.SplitHostPort(addr); err != nil {
    return fmt.Errorf("peer.address not in host:port format: %s", addr)
}

Try / catch

if err := peer.Config(); err != nil {
    if strings.Contains(err.Error(), "peer.address isn't set") {
        return fmt.Errorf("set CORE_PEER_ADDRESS (e.g. peer0.org1.example.com:7051) before starting the peer: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Starting a peer with neither peer.address set in core.yaml nor CORE_PEER_ADDRESS in the environment; an env-var override that resolves to an empty string; a mounted config file that omits the peer.address key.

Common situations: Docker/Kubernetes deployments where CORE_PEER_ADDRESS was dropped from the container env; docker-compose env files with a blank value; copying a minimal core.yaml without the address; secret/config mount ordering wiping environment variables.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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