lima-vm/lima · error

failed to check if the autostart entry for instance %#q is r

Error message

failed to check if the autostart entry for instance %#q is registered: %w

What it means

During a graceful restart, Lima checks whether the instance is registered with an autostart manager (launchd/systemd) so it knows whether the manager will bring the VM back up. If autostart.IsRegistered fails with an error other than ErrNotSupported (e.g. the launchd/systemd backend itself errored), the restart is aborted with this wrapped message naming the instance.

Source

Thrown at pkg/instance/restart.go:29

	"github.com/sirupsen/logrus"

	"github.com/lima-vm/lima/v2/pkg/autostart"
	"github.com/lima-vm/lima/v2/pkg/limatype"
	"github.com/lima-vm/lima/v2/pkg/networks/reconcile"
)

const (
	launchHostAgentForeground = false
)

func Restart(ctx context.Context, inst *limatype.Instance, showProgress bool) error {
	if err := StopGracefully(ctx, inst, true); err != nil {
		return err
	}

	// Network reconciliation will be performed by the process launched by the autostart manager
	if registered, err := autostart.IsRegistered(ctx, inst); err != nil && !errors.Is(err, autostart.ErrNotSupported) {
		return fmt.Errorf("failed to check if the autostart entry for instance %#q is registered: %w", inst.Name, err)
	} else if !registered {
		if err := reconcile.Reconcile(ctx, inst.Name); err != nil {
			return err
		}
	}

	if err := Start(ctx, inst, launchHostAgentForeground, showProgress); err != nil {
		return err
	}

	return nil
}

func RestartForcibly(ctx context.Context, inst *limatype.Instance, showProgress bool) error {
	logrus.Info("Restarting the instance forcibly")
	StopForcibly(inst)

	if registered, err := autostart.IsRegistered(ctx, inst); err != nil && !errors.Is(err, autostart.ErrNotSupported) {

View on GitHub (pinned to dd909d0973)

Solutions

  1. Ensure a working user session (loginctl enable-linger <user> on Linux; a GUI session on macOS).
  2. Run limactl inside a normal user session with DBUS_SESSION_BUS_ADDRESS/systemd user instance available.
  3. If the platform genuinely lacks autostart support, verify errors.Is(err, autostart.ErrNotSupported) - that path is tolerated and would not produce this error.
  4. As a fallback, stop then start the instance manually instead of restart.

Example fix

// before
limactl restart myvm  # over ssh without systemd user session
// after
ssh -t user@host "systemctl --user status"  # verify session, then run restart in that session
# or: limactl stop myvm && limactl start myvm
Defensive patterns

Strategy: try-catch

Validate before calling

// before restart, check the environment
if runtime.GOOS == "linux" {
  if out, err := exec.Command("systemctl", "--user", "is-system-running").Output(); err != nil {
    log.Println("no systemd user session; autostart checks will fail")
  }
}

Try / catch

err := instance.Restart(ctx, inst, true)
if err != nil && strings.Contains(err.Error(), "autostart entry") {
  // fall back: stop then start manually
  _ = instance.StopGracefully(ctx, inst, true)
  err = instance.Start(ctx, inst, "")
}

Prevention

When it happens

Trigger: Calling `limactl restart <inst>` (Restart -> StopGracefully, then autostart.IsRegistered) on macOS when launchd queries fail, or on Linux when systemctl --user queries fail (e.g. no user session bus, systemd not running).

Common situations: Running limactl over SSH or in a container without a systemd user session; DBUS_SESSION_BUS_ADDRESS unset; launchd plist directory unreadable; corrupted launchd/systemd state for the user.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/100c2d9e8ec42dcf. Report an issue: GitHub.