{"record":{"id":"a80081b91d8851b1","repo":"abiosoft/colima","slug":"failed-to-write-dnsmasq-config-w","errorCode":null,"errorMessage":"failed to write dnsmasq config: %w","messagePattern":"failed to write dnsmasq config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/dns.go","lineNumber":86,"sourceCode":"\tfor _, dns := range dnsServers {\n\t\tfmt.Fprintf(&buf, \"server=%s\", dns)\n\t\tfmt.Fprintln(&buf)\n\t}\n\tfmt.Fprintln(&buf) // for cleaner output\n\n\t// set dnsmasq listening interface and address\n\tfmt.Fprintln(&buf, \"interface=eth0\")\n\tfmt.Fprintln(&buf, \"listen-address=\"+internalIP)\n\tfmt.Fprintln(&buf, \"bind-interfaces\")\n\n\t// ensure dnsmasq config directory exists\n\tif err := l.RunQuiet(\"sudo\", \"mkdir\", \"-p\", \"/etc/dnsmasq.d\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to create dnsmasq config directory: %w\", err)\n\t}\n\n\t// write config to dnsmasq directory\n\tif err := l.Write(\"/etc/dnsmasq.d/01-colima.conf\", buf.Bytes()); err != nil {\n\t\treturn fmt.Errorf(\"failed to write dnsmasq config: %w\", err)\n\t}\n\n\t// remove existing resolv.conf file\n\tif err := l.RunQuiet(\"sudo\", \"rm\", \"-f\", \"/etc/resolv.conf\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to remove existing resolv.conf: %w\", err)\n\t}\n\n\t// replace resolv.conf with a custom one\n\tresolvConf := fmt.Sprintf(\"# Generated by Colima\\n\\nnameserver %s\\n\", internalIP)\n\tif err := l.Write(\"/etc/resolv.conf\", []byte(resolvConf)); err != nil {\n\t\treturn fmt.Errorf(\"failed to write resolv.conf: %w\", err)\n\t}\n\n\t// restart dnsmasq service to apply changes\n\tif err := l.RunQuiet(\"sudo\", \"systemctl\", \"restart\", \"dnsmasq\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to restart dnsmasq service: %w\", err)\n\t}\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/dns.go#L68-L104","documentation":"After ensuring /etc/dnsmasq.d exists, Colima writes the generated 01-colima.conf (upstream servers, interface=eth0, bind-interfaces, listen-address) into the guest using its file writer (sudo mkdir of the parent plus `sudo sh -c 'cat > file'` over SSH). This error means writing the config file inside the guest failed, so dnsmasq keeps running without Colima's resolver configuration.","triggerScenarios":"Guest filesystem full or read-only at /etc; sudo policy blocking the write; SSH stream interrupted during transfer; concurrent colima start processes racing to write the same file.","commonSituations":"Tiny disk sizes (e.g. started with --disk 1) filling /; corrupted guest state after forced shutdowns; two colima invocations on the same profile simultaneously.","solutions":["Retry start after a clean stop; transient SSH/write failures usually resolve.","Verify guest disk space (`colima ssh -- df -h /etc`) and grow the disk if full (see the resize flow).","Ensure no parallel colima commands target the same profile at once.","If persistent, inspect guest state with `colima ssh` (test `sudo tee /etc/dnsmasq.d/x`) and recreate the VM if the guest is corrupted (`colima delete && colima start`)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Go: treat write-config failures as retryable once after stop/start; if repeated, check guest disk space via `colima ssh -- df -h` before recreating.","preventionTips":["Provision adequate --disk size upfront","Don't force-stop colima mid-start","Ensure no parallel colima processes on one profile"],"tags":["dns","dnsmasq","guest","filesystem","colima"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}