lima-vm/lima · error
invalid interface %#q for network %#q: %w
Error message
invalid interface %#q for network %#q: %w
What it means
A network's `interface` value (used for bridged networks and to derive file/socket names) must be a valid identifier; otherwise networks.Validate wraps identifiers.Validate's error with the interface and network name.
Source
Thrown at pkg/networks/validate.go:45
// for non-bridged networks, and group defaults to "admin" when unset, so
// only validate those when a value is actually present.
if c.Group != "" {
if err := identifiers.Validate(c.Group); err != nil {
return fmt.Errorf("invalid group %#q: %w", c.Group, err)
}
}
for name, nw := range c.Networks {
if err := identifiers.Validate(name); err != nil {
return fmt.Errorf("invalid network name %#q: %w", name, err)
}
if nw.Mode != "" {
if err := identifiers.Validate(nw.Mode); err != nil {
return fmt.Errorf("invalid mode %#q for network %#q: %w", nw.Mode, name, err)
}
}
if nw.Interface != "" {
if err := identifiers.Validate(nw.Interface); err != nil {
return fmt.Errorf("invalid interface %#q for network %#q: %w", nw.Interface, name, err)
}
}
}
// validate all paths.* values
paths := reflect.ValueOf(&c.Paths).Elem()
pathsMap := make(map[string]string, paths.NumField())
var socketVMNetNotFound bool
for i := range paths.NumField() {
// extract YAML name from struct tag; strip options like "omitempty"
name := paths.Type().Field(i).Tag.Get("yaml")
if i := strings.IndexRune(name, ','); i > -1 {
name = name[:i]
}
path := paths.Field(i).Interface().(string)
pathsMap[name] = path
// varPath will be created securely, but any existing parent directories must already be secure
if name == "varRun" {View on GitHub (pinned to dd909d0973)
Solutions
- Replace the interface value with the bare device identifier (e.g. en0, eth0) with no spaces or extra text.
- Remove any trailing/leading whitespace in the YAML value.
- Re-run validation after the fix.
- If the host interface has a long display name, find its short system name via `networksetup -listallhardwareports` (macOS) or `ip link` (Linux).
Example fix
# before (networks.yaml)
networks:
bridged-en0:
mode: bridged
interface: "en0: Wi-Fi"
# after
networks:
bridged-en0:
mode: bridged
interface: en0 Defensive patterns
Strategy: validation
Validate before calling
function validateInterface(iface, name) {
if (!iface) return null;
if (/\s/.test(iface) || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(iface)) {
return `invalid interface '${iface}' for network ${name}: use bare device name (e.g. en0)`;
}
return null;
} Type guard
function isValidInterface(iface) {
return !iface || (typeof iface === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(iface));
} Prevention
- Use the short OS device name (en0, eth0), not the display name.
- Resolve display names via networksetup -listallhardwareports (macOS) or ip link (Linux).
- Trim whitespace after copy-paste.
- Bridged configs: only set interface when mode is bridged.
When it happens
Trigger: Setting `interface:` in networks.yaml to a value containing whitespace, slashes, or other invalid characters (e.g. a full BSD interface description with spaces) and validating the config.
Common situations: macOS bridged setups where users paste 'en0: Wi-Fi' instead of 'en0'; Windows/Linux interface names with spaces; trailing whitespace from copy-paste.
Related errors
- invalid group %#q: %w
- invalid network name %#q: %w
- invalid mode %#q for network %#q: %w
- path %#q is not an absolute path
- path %#q contains whitespace
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/0cbf27b3891bb550.
Report an issue: GitHub.