lima-vm/lima · error

network %#q is not defined

Error message

network %#q is not defined

What it means

Config.Check verifies that a network name exists in the loaded networks configuration (networks.yaml). If the name is absent from c.Networks, Lima cannot resolve the network and returns 'network %#q is not defined'. This protects VM startup from silently using an unknown network.

Source

Thrown at pkg/networks/commands.go:28

	"os/exec"
	"path/filepath"

	"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
	"github.com/lima-vm/lima/v2/pkg/osutil"
)

const (
	SocketVMNet = "socket_vmnet"
)

// Commands in `sudoers` cannot use quotes, so all arguments are printed via "%s"
// and not "%q". cfg.Paths.* entries must not include any whitespace!

func (c *Config) Check(name string) error {
	if _, ok := c.Networks[name]; ok {
		return nil
	}
	return fmt.Errorf("network %#q is not defined", name)
}

// Usernet returns true if the mode of given network is ModeUserV2.
func (c *Config) Usernet(name string) (bool, error) {
	if nw, ok := c.Networks[name]; ok {
		return nw.Mode == ModeUserV2, nil
	}
	return false, fmt.Errorf("network %#q is not defined", name)
}

// DaemonPath returns the daemon path.
func (c *Config) DaemonPath(daemon string) (string, error) {
	switch daemon {
	case SocketVMNet:
		return c.Paths.SocketVMNet, nil
	default:
		return "", fmt.Errorf("unknown daemon type %#q", daemon)
	}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Add the network to networks.yaml under the networks: key
  2. Fix the network name typo in the instance's lima.yaml
  3. Run limactl or check the config paths to confirm which networks file is being loaded

Example fix

// networks.yaml
// before
networks: []
// after
networks:
  - name: bridged
    mode: bridged
    interface: en0
Defensive patterns

Strategy: validation

Validate before calling

cfg, err := networks.LoadConfig()
if err != nil { return err }
if err := cfg.Check(name); err != nil {
    return fmt.Errorf("fix networks.yaml or instance config: %w", err)
}

Try / catch

if err := cfg.Check(netName); err != nil {
    return fmt.Errorf("network %q undefined; add it to $LIMA_HOME/_config/networks.yaml", netName)
}

Prevention

When it happens

Trigger: Calling Check(name) with a network name that does not appear in the networks config map — e.g. a lima.yaml network stanza referencing a name not present in networks.yaml, or a typo in the name.

Common situations: User references a custom network in instance config without defining it in $LIMA_HOME/_config/networks.yaml; misspelled network name like 'bridgde'; upstream renamed a default network.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/f6f136b430356006. Report an issue: GitHub.