abiosoft/colima · error
failed to write dnsmasq config: %w
Error message
failed to write dnsmasq config: %w
What it means
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.
Source
Thrown at environment/vm/lima/dns.go:86
for _, dns := range dnsServers {
fmt.Fprintf(&buf, "server=%s", dns)
fmt.Fprintln(&buf)
}
fmt.Fprintln(&buf) // for cleaner output
// set dnsmasq listening interface and address
fmt.Fprintln(&buf, "interface=eth0")
fmt.Fprintln(&buf, "listen-address="+internalIP)
fmt.Fprintln(&buf, "bind-interfaces")
// ensure dnsmasq config directory exists
if err := l.RunQuiet("sudo", "mkdir", "-p", "/etc/dnsmasq.d"); err != nil {
return fmt.Errorf("failed to create dnsmasq config directory: %w", err)
}
// write config to dnsmasq directory
if err := l.Write("/etc/dnsmasq.d/01-colima.conf", buf.Bytes()); err != nil {
return fmt.Errorf("failed to write dnsmasq config: %w", err)
}
// remove existing resolv.conf file
if err := l.RunQuiet("sudo", "rm", "-f", "/etc/resolv.conf"); err != nil {
return fmt.Errorf("failed to remove existing resolv.conf: %w", err)
}
// replace resolv.conf with a custom one
resolvConf := fmt.Sprintf("# Generated by Colima\n\nnameserver %s\n", internalIP)
if err := l.Write("/etc/resolv.conf", []byte(resolvConf)); err != nil {
return fmt.Errorf("failed to write resolv.conf: %w", err)
}
// restart dnsmasq service to apply changes
if err := l.RunQuiet("sudo", "systemctl", "restart", "dnsmasq"); err != nil {
return fmt.Errorf("failed to restart dnsmasq service: %w", err)
}
View on GitHub (pinned to c3a5f9184d)
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`).
Defensive patterns
Strategy: retry
Try / catch
Go: treat write-config failures as retryable once after stop/start; if repeated, check guest disk space via `colima ssh -- df -h` before recreating.
Prevention
- Provision adequate --disk size upfront
- Don't force-stop colima mid-start
- Ensure no parallel colima processes on one profile
When it happens
Trigger: 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.
Common situations: Tiny disk sizes (e.g. started with --disk 1) filling /; corrupted guest state after forced shutdowns; two colima invocations on the same profile simultaneously.
Related errors
- failed to create dnsmasq config directory: %w
- failed to remove existing resolv.conf: %w
- failed to write resolv.conf: %w
- failed to restart dnsmasq service: %w
- cannot read file '%s': %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/a80081b91d8851b1.
Report an issue: GitHub.