hashicorp/nomad · error

invalid interface name %q

Error message

invalid interface name %q

What it means

After rendering the network_interface template, parseSingleInterfaceTemplate validates that the result is a real network interface using net.InterfaceByName. If the OS reports no interface with that name, the code returns 'invalid interface name %q' instead of continuing with a bogus interface.

Source

Thrown at command/agent/config.go:2464

		// unable to parse template "{{printfl \"en50\"}}": template: sockaddr.Parse:1: function "printfl" not defined
		return "", err
	}

	// Remove any extra empty space around the rendered result and check if the
	// result is also not empty if the user provided a template.
	out = strings.TrimSpace(out)
	if tpl != "" && out == "" {
		return "", fmt.Errorf("template %q evaluated to empty result", tpl)
	}

	// `template.Parse` returns a space-separated list of results, but on
	// Windows network interfaces are allowed to have spaces, so there is no
	// guaranteed separators that we can use to test if the template returned
	// multiple interfaces.
	// The test below checks if the template results to a single valid interface.
	_, err = net.InterfaceByName(out)
	if err != nil {
		return "", fmt.Errorf("invalid interface name %q", out)
	}

	return out, nil
}

// parseMultipleIPTemplate is used as a helper function to parse out a multiple IP
// addresses from a config parameter.
func parseMultipleIPTemplate(ipTmpl string) ([]string, error) {
	out, err := template.Parse(ipTmpl)
	if err != nil {
		return []string{}, fmt.Errorf("Unable to parse address template %q: %v", ipTmpl, err)
	}

	ips := strings.Split(out, " ")
	if len(ips) == 0 {
		return []string{}, errors.New("No addresses found, please configure one.")
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Run `ip link` (Linux) or `ifconfig` (macOS/BSD) and use an existing interface name
  2. Prefer a template like {{ GetInterfaceIP "eth0" }} over hardcoding names
  3. Update machine provisioning/terraform so interface names are consistent
  4. Check the quoted name in the error against the host's actual interfaces

Example fix

// before
client { network_interface = "eth1" } # does not exist
// after
client { network_interface = "eth0" }
Defensive patterns

Strategy: validation

Validate before calling

name := strings.TrimSpace(rendered)
if _, err := net.InterfaceByName(name); err != nil {
	// not a real interface: pick one from `ip link`
}

Prevention

When it happens

Trigger: client.network_interface (after template evaluation) naming an interface that does not exist on the host, e.g. 'eth1' on a single-NIC machine, or a template filter returning a raw IP rather than an interface name expected by InterfaceByName.

Common situations: Hardcoded interface names that differ across environments (eth0 vs ens192 vs enp0s3); renamed NICs after re-provisioning; typos in static interface names in config.

Related errors


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