{"record":{"id":"d578cd425212ae6d","repo":"abiosoft/colima","slug":"the-last-octet-of-gateway-q-is-not-2","errorCode":null,"errorMessage":"the last octet of gateway %q is not 2","messagePattern":"the last octet of gateway %q is not 2","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/configmanager/configmanager.go","lineNumber":144,"sourceCode":"func Teardown() error {\n\tdir := config.CurrentProfile().ConfigDir()\n\tif _, err := os.Stat(dir); err == nil {\n\t\treturn os.RemoveAll(dir)\n\t}\n\treturn nil\n}\n\n// Validates that gateway is a valid IPv4 address and that the last octet is “2”.\n// Lima uses the last octet as 2 for gateways.\nfunc validateGatewayAddress(gateway net.IP) error {\n\tip4 := gateway.To4()\n\tif ip4 == nil {\n\t\treturn fmt.Errorf(\"gateway %q is not IPv4\", gateway)\n\t}\n\n\t// Check last octet\n\tif ip4[3] != 2 {\n\t\treturn fmt.Errorf(\"the last octet of gateway %q is not 2\", gateway)\n\t}\n\n\treturn nil\n}\n\n// validateMounts ensures mount paths do not contain spaces, which are not\n// supported by the underlying Lima runtime and otherwise fail silently.\n// See https://github.com/abiosoft/colima/issues/1471.\nfunc validateMounts(mounts []config.Mount) error {\n\tfor _, m := range mounts {\n\t\tfor _, p := range []string{m.Location, m.MountPoint} {\n\t\t\tif strings.Contains(p, \" \") {\n\t\t\t\treturn fmt.Errorf(\"mount path with spaces is not supported by the underlying Lima runtime: %q\", p)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/config/configmanager/configmanager.go#L126-L162","documentation":"validateGatewayAddress enforces Lima's addressing convention: after confirming the gateway is IPv4, the fourth octet (ip4[3]) must be exactly 2. Lima reserves .1 for the host-side interface and .2 for the gateway inside the virtual network, so any other final octet is rejected with the address echoed.","triggerScenarios":"gatewayAddress set to an IPv4 address ending in .1, .254, or any octet other than 2, such as 192.168.104.1 copied from a typical router gateway configuration.","commonSituations":"Reusing a home or office router address (conventionally .1) as the colima gateway; network plans where .2 is already assigned to another host; not realizing colima must own the .2 address in its subnet.","solutions":["Change the last octet to 2, e.g. 192.168.104.2, within a subnet that does not collide with the LAN","Pick a different /24 subnet if .2 is already spoken for","Omit gatewayAddress to keep default network settings"],"exampleFix":"# before\nnetwork:\n  gatewayAddress: 192.168.104.1\n\n# after\nnetwork:\n  gatewayAddress: 192.168.104.2","handlingStrategy":"validation","validationCode":"if ip4 := c.Network.GatewayAddress.To4(); ip4 != nil && ip4[3] != 2 {\n    // adjust the last octet to 2 before running ValidateConfig\n}","typeGuard":null,"tryCatchPattern":"if err := configmanager.ValidateConfig(c); err != nil {\n    if strings.Contains(err.Error(), \"last octet\") {\n        // Lima reserves .2 for the gateway; change e.g. 192.168.104.1 to 192.168.104.2\n    }\n}","preventionTips":["Remember the .2 convention: host is .1, gateway is .2 in Lima networks","Choose a colima subnet that does not collide with the LAN router addressing","Document gateway requirements in shared network presets"],"tags":["config","validation","network","gateway"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}