hashicorp/nomad · error

cannot use address_mode="alloc": no allocation network statu

Error message

cannot use address_mode="alloc": no allocation network status reported

What it means

Nomad's client service registration helper GetAddress resolves the IP/port a service should advertise. When the service is configured with address_mode="alloc", the address must come from the allocation's reported network status. This error is thrown when that network status is nil, so no allocation-level IP is available to advertise.

Source

Thrown at client/serviceregistration/address.go:145

			// never intended it to be a numeric and it creates a
			// confusing error message
			return "", 0, fmt.Errorf("invalid port label %q: port labels in driver address_mode must be numeric or in the driver's port map", portLabel)
		}
		if port <= 0 {
			return "", 0, fmt.Errorf("invalid port: %q: port must be >0", portLabel)
		}

		return driverNet.IP, port, nil

	case structs.AddressModeAlloc, structs.AddressModeAllocIPv6:
		// Cannot use address mode alloc with custom advertise address.
		if address != "" {
			return "", 0, fmt.Errorf("cannot use custom advertise address with %q address mode", structs.AddressModeAlloc)
		}

		// Going to need a network for this.
		if netStatus == nil {
			return "", 0, fmt.Errorf(`cannot use address_mode="alloc": no allocation network status reported`)
		}

		// If no port label is specified just return the IP
		if portLabel == "" {
			return getAddressPort(addressMode, netStatus, 0)
		}

		// If port is a label and is found then return it
		if port, ok := ports.Get(portLabel); ok {
			// Use port.To value unless not set
			if port.To > 0 {
				return getAddressPort(addressMode, netStatus, port.To)
			}

			return getAddressPort(addressMode, netStatus, port.Value)
		}

		// Check if port is a literal number

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set an explicit address_mode on the service (e.g. address_mode="host" or "driver") so a network status is not required
  2. Define a network block with a dynamic/static port in the task group so the allocation gets network status
  3. Verify the task driver supports and reports allocation network status (check driver docs/versions)
  4. Upgrade Nomad client/plugins if the driver should report network status but does not

Example fix

// before
service {
  name = "api"
  port = "http"
  address_mode = "alloc"
}
// after
service {
  name = "api"
  port = "http"
  address_mode = "host"
}
Defensive patterns

Strategy: validation

Validate before calling

if service.AddressMode == "alloc" && workload.NetworkStatus == nil {
    return fmt.Errorf("service %q: address_mode=alloc requires allocation network status; use address_mode=host or define a network block", service.Name)
}

Type guard

func hasAllocNetworkStatus(w Workload) bool {
    return w.NetworkStatus != nil && w.NetworkStatus.Address != ""
}

Prevention

When it happens

Trigger: A service/check stanza uses address_mode="alloc" (explicitly or via default in host/network modes) but workload.NetworkStatus is nil — i.e., the allocation has no network status reported by the driver/plugins when GetAddress is invoked during serviceRegs or checkRegs.

Common situations: Running tasks with a driver that does not report network status (e.g., some non-network-isolating drivers) while services default to alloc address mode; Nomad agents older than 0.12-style network status plumbing; task group without a configured network block where the allocation never gets a network status populated.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/5a6634e785d811cb. Report an issue: GitHub.