{"record":{"id":"92d95a9f6dceebba","repo":"abiosoft/colima","slug":"failed-to-write-resolv-conf-w","errorCode":null,"errorMessage":"failed to write resolv.conf: %w","messagePattern":"failed to write resolv\\.conf: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/dns.go","lineNumber":97,"sourceCode":"\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\n\treturn nil\n}\n","sourceCodeStart":79,"sourceCodeEnd":107,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/dns.go#L79-L107","documentation":"After removing the old resolv.conf, Colima writes a generated replacement ('# Generated by Colima\\n\\nnameserver <internalIP>') so guest lookups go through the in-guest dnsmasq listening on the internal IP. This error means that write (`cat > /etc/resolv.conf` via sudo over SSH) failed, leaving the guest temporarily without a resolv.conf if removal already succeeded.","triggerScenarios":"Same class as the remove step: read-only or immutable /etc/resolv.conf target, full guest disk, sudo/SSH failure mid-write. Because the previous step already deleted the file, a failure here can leave DNS fully broken inside the guest until restarted.","commonSituations":"Hardened/custom images protecting resolv.conf; disk-full guests; SSH instability; interrupted colima start (Ctrl-C) during post-start actions.","solutions":["Immediately retry `colima stop && colima start` so the whole DNS setup re-runs and restores resolv.conf.","Fix guest filesystem issues (space, immutability) if the error repeats (`colima ssh -- lsattr /etc/resolv.conf; sudo chattr -i /etc/resolv.conf`).","Use a simpler DNS mode that skips in-guest dnsmasq.","Recreate the VM if the guest remains broken."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Go: on resolv.conf write failure, immediately schedule stop/start so DNS setup re-runs; if persistent, treat guest as corrupted and recreate profile.","preventionTips":["Keep guest filesystem writable and with free space","Never Ctrl-C colima during post-start actions","Verify custom images don't protect /etc/resolv.conf"],"tags":["dns","resolv-conf","guest","colima","filesystem"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}