Skip to content

limactl start fails with stale ha.sock/ha.pid from unclean shutdown #5075

@loncharles

Description

@loncharles

If the system shuts down before limactl start --foreground finishes cleanup (signal handler in hostagent.go), stale ha.pid and ha.sock files remain in the instance directory. On the next boot, limactl start tries to connect to the stale ha.sock, gets connection refused, and exits with a fatal error instead of cleaning up and starting fresh.

The hostagent command already has defer os.RemoveAll(pidfile) and signal handling via signalCh, but macOS may kill the process before cleanup completes during a fast shutdown. limactl start could check whether the PID in ha.pid is actually running before attempting to connect to ha.sock, and clean up stale files if it's not.

This is one of several issues that make Lima unusable for unattended auto-start via LaunchDaemon. See also #2252.

Environment: macOS 15.7.7, Lima 2.1.x (fork), LaunchDaemon with RunAtLoad.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions