lima-vm/lima · error
failed to remove socket %#q: %w
Error message
failed to remove socket %#q: %w
What it means
At Start time the krunkit driver runs cleanupStaleSockets to delete stale Unix sockets (the guestagent socket and the vsock forwarding socket) from the instance directory. If os.RemoveAll on any of these paths fails, the error is wrapped with `failed to remove socket %#q` and joined into a single error returned to Start.
Source
Thrown at pkg/driver/krunkit/krunkit_driver_darwin_arm64.go:418
func (l *LimaKrunkitDriver) AdditionalSetupForSSH(_ context.Context) error {
return nil
}
// Currently, Krunkit does not clean-up the vsock unix socket when the VM stops
// Issue: https://github.com/containers/krunkit/issues/101
func (l *LimaKrunkitDriver) cleanupStaleSockets() error {
if l.Instance == nil || l.Instance.Dir == "" {
return nil
}
var errs []error
for _, sock := range []string{
filepath.Join(l.Instance.Dir, filenames.GuestAgentSock),
filepath.Join(l.Instance.Dir, sshVsockSock),
} {
if err := os.RemoveAll(sock); err != nil {
errs = append(errs, fmt.Errorf("failed to remove socket %#q: %w", sock, err))
}
}
return errors.Join(errs...)
}
View on GitHub (pinned to dd909d0973)
Solutions
- Check ownership/permissions of ~/.lima/<instance> and fix: `ls -la` then chown/chmod as needed
- Remove the stale socket files manually and retry `limactl start`
- If the whole instance is broken, delete it with `limactl delete -f <instance>` and recreate
Example fix
// before sudo limactl start myvm # creates root-owned files // after limactl start myvm # run as the same user; avoid sudo
Defensive patterns
Strategy: try-catch
Validate before calling
for _, sock := range []string{"ga.sock", "ssh-vsock.sock"} {
if info, err := os.Stat(filepath.Join(instanceDir, sock)); err == nil && !isWritableDir(instanceDir) {
return fmt.Errorf("instance dir %s not writable; cannot clean %s", instanceDir, sock)
}
} Try / catch
err := limactl.Start(ctx, inst)
if strings.Contains(err.Error(), "failed to remove socket") {
// inspect permissions of the named socket in instance dir, fix, retry
} Prevention
- Never run limactl with sudo (avoids root-owned files)
- Keep ${LIMA_HOME} on a local writable volume
- After crashes, manually clear stale sockets in the instance dir
When it happens
Trigger: os.RemoveAll failing on ${instance-dir}/ga.sock (filenames.GuestAgentSock) or the ssh-vsock socket — e.g. permission problems on the instance dir, read-only filesystem, or a file held in a state the OS refuses to remove.
Common situations: Instance directory owned by another user or created with root (sudo-started Lima); running Lima home on a network/immutable volume; corrupted instance dir after a crash.
Related errors
- failed to create temp file: %w
- failed to write temp plist: %w
- failed to register instance %#q to start at login: %w
- failed to unregister instance %#q from start at login: %w
- instance %#q directory %#q exists but its %#q could not be r
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/83621c51b0657ca0.
Report an issue: GitHub.