{"record":{"id":"14d50d9213a51d11","repo":"lima-vm/lima","slug":"s-daemon-for-q-network-w-s","errorCode":null,"errorMessage":"%s daemon for %#q network %w%s","messagePattern":"(.+?) daemon for %#q network %w(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/networks/reconcile/reconcile.go","lineNumber":312,"sourceCode":"\t\t\t\treturn ctx.Err()\n\t\t\tcase <-time.After(backoff):\n\t\t\t}\n\t\t}\n\t\tcmd, err := startDaemon(ctx, cfg, name, daemon)\n\t\tif err != nil {\n\t\t\treturn err // infrastructure failure (sudo/exec) — not transient\n\t\t}\n\t\terr = waitForDaemon(ctx, cmd, pidFile, startTimeout)\n\t\tif err == nil {\n\t\t\treturn nil\n\t\t}\n\t\t// Only an early exit (the transient XPC race) is retried; everything else\n\t\t// is surfaced immediately.\n\t\tif _, ok := errors.AsType[*daemonExitedError](err); !ok {\n\t\t\t// A stuck (still-running) daemon gets its stderr appended; PID-read and\n\t\t\t// context errors propagate as-is.\n\t\t\tif _, ok := errors.AsType[*daemonStuckError](err); ok {\n\t\t\t\treturn fmt.Errorf(\"%s daemon for %#q network %w%s\", daemon, name, err, stderrHint(stderrLog))\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tlastErr = err // process exited early — retry\n\t}\n\treturn fmt.Errorf(\"%s daemon for %#q network failed to start after %d attempts: %w%s\",\n\t\tdaemon, name, maxAttempts, lastErr, stderrHint(stderrLog))\n}\n\n// waitForDaemon waits until the daemon writes its PID file (success), exits without\n// one (returns *daemonExitedError so the caller can retry), or stays alive past\n// timeout without a PID file (returns *daemonStuckError). A stuck or cancelled\n// process is killed and reaped.\nfunc waitForDaemon(ctx context.Context, cmd *exec.Cmd, pidFile string, timeout time.Duration) error {\n\twaitCh := make(chan error, 1)\n\tgo func() { waitCh <- cmd.Wait() }()\n\n\ttimer := time.NewTimer(timeout)","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/networks/reconcile/reconcile.go#L294-L330","documentation":"Lima fails to start the network daemon (e.g. socket_vmnet) for a named network because the daemon stayed alive past the 30s startup timeout without ever writing its PID file. This is a non-transient 'stuck daemon' condition, so startDaemonWithRetry returns immediately (no retry), appending the daemon's captured stderr or a pointer to its stderr log to help diagnosis.","triggerScenarios":"Calling startNetwork/Reconcile for a sudo-managed network where the daemon process runs but never writes cfg.PIDFile(name, daemon) within 30s — e.g. socket_vmnet blocked waiting on input, a stale/hung process, or the daemon wedged before creating its PID file.","commonSituations":"socket_vmnet hanging after launch (wrong binary or args), a leftover orphaned daemon holding the unix socket, permission/sandbox issues making the daemon block on a resource, or a stale PID file path pointing at a directory that can't be written.","solutions":["Read the daemon stderr shown in the message (or the referenced log file under ~/.lima/networks) to see where the daemon is blocked","Kill any leftover daemon processes (stale socket_vmnet instances) and delete stale PID files, then retry limactl start","Verify the socketVMNet binary path and network switch device in networks.yaml are correct","Reinstall/upgrade socket_vmnet (e.g. brew upgrade socket_vmnet) if the binary is broken"],"exampleFix":"// before: orphaned socket_vmnet keeps running, PID file never written\n$ sudo pkill -f socket_vmnet\n$ rm ~/.lima/networks/lima-shared_pid\n// after: retry\n$ limactl start","handlingStrategy":"validation","validationCode":"pidFile := filepath.Join(os.Getenv(\"HOME\"), \".lima\", \"networks\", \"<name>_pid\")\nif data, err := os.ReadFile(pidFile); err == nil {\n    var pid int\n    if _, e := fmt.Sscanf(string(data), \"%d\", &pid); e != nil || pid <= 0 {\n        os.Remove(pidFile) // stale/corrupt before starting\n    }\n}","typeGuard":"func isDaemonStuckError(err error) bool {\n    var e *daemonStuckError\n    return errors.As(err, &e)\n}","tryCatchPattern":"if err := limactlStart(); err != nil {\n    var stuck *daemonStuckError\n    if errors.As(err, &stuck) {\n        // kill orphaned daemon, remove PID file, retry once\n    }\n}","preventionTips":["Kill leftover socket_vmnet processes and remove stale PID files under ~/.lima/networks before starting","Keep socket_vmnet updated (brew upgrade socket_vmnet)","Check the daemon stderr log at ~/.lima/networks when startup hangs","Avoid running multiple Lima homes (LIMA_HOME) against the same network"],"tags":["network","socket-vmnet","pid-file","daemon-startup","macos"],"backgroundTag":"daemon-start-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}