hashicorp/nomad · error

failed to load CNI config: %v

Error message

failed to load CNI config: %v

What it means

newCNINetworkConfigurator loads the CNI network configuration file for the given network name from cni_conf_dir via loadCNIConf. If no matching CNI conf JSON exists or it fails to parse, this error wraps the cause. The bridge/consul CNI setup cannot proceed without the plugin chain definition.

Source

Thrown at client/allocrunner/networking_cni.go:69

	defaultCNIInterfacePrefix = "eth"
)

type cniNetworkConfigurator struct {
	cni                     cni.CNI
	confParser              *cniConfParser
	ignorePortMappingHostIP bool
	nodeAttrs               map[string]string
	nodeMeta                map[string]string
	rand                    *rand.Rand
	logger                  log.Logger
	nsOpts                  *nsOpts
	newIPTables             func(structs.NodeNetworkAF) (IPTablesCleanup, error)
}

func newCNINetworkConfigurator(logger log.Logger, cniPath, cniInterfacePrefix, cniConfDir, networkName string, ignorePortMappingHostIP bool, node *structs.Node) (*cniNetworkConfigurator, error) {
	parser, err := loadCNIConf(cniConfDir, networkName)
	if err != nil {
		return nil, fmt.Errorf("failed to load CNI config: %v", err)
	}

	return newCNINetworkConfiguratorWithConf(logger, cniPath, cniInterfacePrefix, ignorePortMappingHostIP, parser, node)
}

func newCNINetworkConfiguratorWithConf(logger log.Logger, cniPath, cniInterfacePrefix string, ignorePortMappingHostIP bool, parser *cniConfParser, node *structs.Node) (*cniNetworkConfigurator, error) {
	conf := &cniNetworkConfigurator{
		confParser:              parser,
		rand:                    rand.New(rand.NewSource(time.Now().Unix())),
		logger:                  logger,
		ignorePortMappingHostIP: ignorePortMappingHostIP,
		nodeAttrs:               node.Attributes,
		nodeMeta:                node.Meta,
		nsOpts:                  &nsOpts{},
		newIPTables:             newIPTablesCleanup,
	}
	if cniPath == "" {
		if cniPath = os.Getenv(envCNIPath); cniPath == "" {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Create a CNI config file named after the network (e.g. nomad.conflist) in the configured cni_config_dir with a valid bridge/loopback plugin chain.
  2. Ensure client config cni_config_dir points at the directory containing the CNI conf files.
  3. Validate the CNI JSON (jq) and fix syntax/spec errors.
  4. Re-run the node's provisioning that installs CNI configs (e.g. nomad init or consul-cni install scripts).
  5. If not using bridge networking intentionally, disable client bridge config so this initializer isn't hit.

Example fix

// before: /etc/cni/nomad.conf (invalid)
{"cniVersion": "0.4.0"
// after: nomad.conflist
{"cniVersion":"0.4.0","name":"nomad","plugins":[{"type":"bridge","bridge":"nomad"},{"type":"loopback"},{"type":"firewall"}]}
Defensive patterns

Strategy: validation

Validate before calling

// before starting client with bridge networking
conf="$CNI_CONF_DIR/${NETWORK_NAME}.conflist"
[ -f "$conf" ] && jq -e '.name, .cniVersion, .plugins' "$conf" >/dev/null || echo "CNI conf missing/invalid: $conf"

Prevention

When it happens

Trigger: loadCNIConf(cniConfDir, networkName) errors during client setup (called from newNetworkConfigurator): the conf dir has no file whose name matches networkName, the file is not valid JSON/CNI spec, or the dir path is wrong.

Common situations: client config 'bridge_network_name' (default 'nomad') with no corresponding /opt/cni/nomad or cni_conf_dir file; CNI configs deleted after host reboot (tmpfs); manually edited CNI JSON with syntax errors; wrong cni_config_dir path in client config.

Related errors


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