{"record":{"id":"ad04d85f07c4dcaf","repo":"lima-vm/lima","slug":"network-q-already-exists","errorCode":null,"errorMessage":"network %#q already exists","messagePattern":"network %#q already exists","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/network.go","lineNumber":182,"sourceCode":"\tflags.String(\"mode\", networks.ModeUserV2, \"mode\")\n\t_ = cmd.RegisterFlagCompletionFunc(\"mode\", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {\n\t\treturn networks.Modes, cobra.ShellCompDirectiveNoFileComp\n\t})\n\tflags.String(\"gateway\", \"\", \"gateway, e.g., \\\"192.168.42.1/24\\\"\")\n\tflags.String(\"interface\", \"\", \"interface for bridged mode\")\n\t_ = cmd.RegisterFlagCompletionFunc(\"interface\", bashFlagCompleteNetworkInterfaceNames)\n\treturn cmd\n}\n\nfunc networkCreateAction(cmd *cobra.Command, args []string) error {\n\tname := args[0]\n\t// LoadConfig ensures existence of networks.yaml\n\tconfig, err := networks.LoadConfig()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif _, ok := config.Networks[name]; ok {\n\t\treturn fmt.Errorf(\"network %#q already exists\", name)\n\t}\n\n\tflags := cmd.Flags()\n\tmode, err := flags.GetString(\"mode\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tgateway, err := flags.GetString(\"gateway\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tintf, err := flags.GetString(\"interface\")\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/network.go#L164-L200","documentation":"`limactl network create <name>` refuses to create a network whose name already exists in networks.yaml. After LoadConfig ensures the file exists, the action checks config.Networks[name] and returns this error from cmd/limactl/network.go:182. networks.yaml holds named virtual networks shared across instances.","triggerScenarios":"`limactl network create <name> ...` where <name> is already a key under .networks in $LIMA_HOME/_config/networks.yaml (created earlier, manually, or by another tool).","commonSituations":"Re-running an idempotent provisioning script that recreates networks; name collision with a default/manual network; typos reusing an existing name unintentionally.","solutions":["Inspect the existing entry: `limactl network list` or read networks.yaml, and skip creation if it's already correct","Choose a different name for the new network","Modify the existing network with `limactl network edit <name>` instead of create","Make scripts idempotent: check existence before `network create`"],"exampleFix":"// before\nlimactl network create shared\n# Error: network \"shared\" already exists\n// after\nlimactl network list | grep -q shared || limactl network create shared --mode shared","handlingStrategy":"validation","validationCode":"name=\"shared\"\nlimactl network list 2>/dev/null | grep -qw \"$name\" && echo \"network $name exists, skipping create\" || limactl network create \"$name\" --mode shared","typeGuard":null,"tryCatchPattern":"if err := networkCreateAction(cmd, args); err != nil {\n\tif strings.Contains(err.Error(), \"already exists\") {\n\t\treturn nil // treat as idempotent success\n\t}\n\treturn err\n}","preventionTips":["Make provisioning scripts idempotent: list/grep before create","Use `limactl network edit` to change existing networks","Keep network names unique and namespaced (e.g. team-net-1)"],"tags":["network","cli","config"],"backgroundTag":"resource-already-exists","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}