{"record":{"id":"f6f136b430356006","repo":"lima-vm/lima","slug":"network-q-is-not-defined","errorCode":null,"errorMessage":"network %#q is not defined","messagePattern":"network %#q is not defined","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/networks/commands.go","lineNumber":28,"sourceCode":"\t\"os/exec\"\n\t\"path/filepath\"\n\n\t\"github.com/lima-vm/lima/v2/pkg/limatype/dirnames\"\n\t\"github.com/lima-vm/lima/v2/pkg/osutil\"\n)\n\nconst (\n\tSocketVMNet = \"socket_vmnet\"\n)\n\n// Commands in `sudoers` cannot use quotes, so all arguments are printed via \"%s\"\n// and not \"%q\". cfg.Paths.* entries must not include any whitespace!\n\nfunc (c *Config) Check(name string) error {\n\tif _, ok := c.Networks[name]; ok {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"network %#q is not defined\", name)\n}\n\n// Usernet returns true if the mode of given network is ModeUserV2.\nfunc (c *Config) Usernet(name string) (bool, error) {\n\tif nw, ok := c.Networks[name]; ok {\n\t\treturn nw.Mode == ModeUserV2, nil\n\t}\n\treturn false, fmt.Errorf(\"network %#q is not defined\", name)\n}\n\n// DaemonPath returns the daemon path.\nfunc (c *Config) DaemonPath(daemon string) (string, error) {\n\tswitch daemon {\n\tcase SocketVMNet:\n\t\treturn c.Paths.SocketVMNet, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unknown daemon type %#q\", daemon)\n\t}","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/networks/commands.go#L10-L46","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the network to networks.yaml under the networks: key","Fix the network name typo in the instance's lima.yaml","Run limactl or check the config paths to confirm which networks file is being loaded"],"exampleFix":"// networks.yaml\n// before\nnetworks: []\n// after\nnetworks:\n  - name: bridged\n    mode: bridged\n    interface: en0","handlingStrategy":"validation","validationCode":"cfg, err := networks.LoadConfig()\nif err != nil { return err }\nif err := cfg.Check(name); err != nil {\n    return fmt.Errorf(\"fix networks.yaml or instance config: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.Check(netName); err != nil {\n    return fmt.Errorf(\"network %q undefined; add it to $LIMA_HOME/_config/networks.yaml\", netName)\n}","preventionTips":["Keep instance lima.yaml network names in sync with networks.yaml","Run Check(name) early during config load, not at VM start","Avoid hand-editing network names; use limactl-managed defaults"],"tags":["network","config","validation","go"],"backgroundTag":"network-not-defined","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}