{"record":{"id":"4c0044a497c91f0b","repo":"lima-vm/lima","slug":"s-driver-is-running-but-host-agent-is-not","errorCode":null,"errorMessage":"%s driver is running but host agent is not","messagePattern":"(.+?) driver is running but host agent is not","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/instance.go","lineNumber":194,"sourceCode":"func inspectStatusWithPIDFiles(instDir string, inst *limatype.Instance, y *limatype.LimaYAML) {\n\tvar err error\n\tinst.DriverPID, err = ReadPIDFile(filepath.Join(instDir, filenames.PIDFile(*y.VMType)))\n\tif err != nil {\n\t\tinst.Status = limatype.StatusBroken\n\t\tinst.Errors = append(inst.Errors, err)\n\t}\n\n\tif inst.Status == limatype.StatusUnknown {\n\t\tswitch {\n\t\tcase inst.HostAgentPID > 0 && inst.DriverPID > 0:\n\t\t\tinst.Status = limatype.StatusRunning\n\t\tcase inst.HostAgentPID == 0 && inst.DriverPID == 0:\n\t\t\tinst.Status = limatype.StatusStopped\n\t\tcase inst.HostAgentPID > 0 && inst.DriverPID == 0:\n\t\t\tinst.Errors = append(inst.Errors, errors.New(\"host agent is running but driver is not\"))\n\t\t\tinst.Status = limatype.StatusBroken\n\t\tdefault:\n\t\t\tinst.Errors = append(inst.Errors, fmt.Errorf(\"%s driver is running but host agent is not\", inst.VMType))\n\t\t\tinst.Status = limatype.StatusBroken\n\t\t}\n\t}\n}\n\n// ReadPIDFile returns 0 if the PID file does not exist, was written during a previous boot\n// of the host, or the process has already terminated (in which case the PID file will be\n// removed).\nfunc ReadPIDFile(path string) (int, error) {\n\t// The boot is checked before the PID is read, so that a PID file of a previous boot is\n\t// never trusted, not even when another process refreshes the marker in between.\n\tif previousBoot, err := pidFileFromPreviousBoot(path); err != nil {\n\t\treturn 0, err\n\t} else if previousBoot {\n\t\t// The PID was recorded before the last reboot, so it is meaningless now: it may\n\t\t// have been reused by an unrelated process, which must not be signaled. Removing\n\t\t// the file is left to WritePIDFile, which knows that no other process is writing\n\t\t// a PID file of the current boot into the same directory.","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/store/instance.go#L176-L212","documentation":"The mirror case of error 927: the driver (VM) process is alive but the host agent PID file is empty/gone. inspectStatusWithPIDFiles marks the instance Broken with '%s driver is running but host agent is not', naming the VM type (qemu, vz, ...).","triggerScenarios":"HostAgentPID == 0 && DriverPID > 0: ha.pid missing/emptied while the VM driver process still runs — hostagent crashed, PID file deleted, or instance dir partially cleaned while the VM keeps running.","commonSituations":"User deleted files under ~/.lima/<inst> while the VM ran; hostagent crashed after provisioning; concurrent limactl commands raced and removed PID files; kill of hostagent during shutdown left the VM orphaned.","solutions":["Find and kill the orphaned VM process (pgrep qemu-system / vz process) listed by the driver PID file","Remove leftover PID files and run `limactl start <inst>` to provision cleanly","Run `limactl delete -f <inst>` if the instance is no longer needed, to force-clean","Check hostagent stderr logs for the crash cause before restarting"],"exampleFix":"// before: qemu running, ha.pid gone -> Broken\n// after\npkill -f 'qemu-system.*myvm'; limactl start myvm","handlingStrategy":"validation","validationCode":"haPid := store.ReadPIDFile(filepath.Join(instDir, \"ha.pid\"))\ndrvPid := store.ReadPIDFile(filepath.Join(instDir, \"vm.pid\"))\nif drvPid > 0 && haPid == 0 {\n    // orphaned VM: kill the driver process before restarting the instance\n}","typeGuard":null,"tryCatchPattern":"inst, err := store.Inspect(ctx, instDir)\nif inst.Status == limatype.StatusBroken {\n    for _, e := range inst.Errors {\n        if strings.Contains(e.Error(), \"driver is running but host agent is not\") {\n            // kill orphaned VM process by driver PID, then clean PID files and start\n        }\n    }\n}","preventionTips":["Do not delete files under ~/.lima/<inst> while the VM is running","Avoid running concurrent limactl commands against the same instance","If hostagent crashes repeatedly, check ha_stderr.log and file a Lima issue"],"tags":["lima","driver","orphaned-process","pid-files"],"backgroundTag":"orphaned-vm-process","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}