lima-vm/lima · error

no socket_vmnet networks defined

Error message

no socket_vmnet networks defined

What it means

After iterating all network entries, buildNetworkArgs returns `no socket_vmnet networks defined` if the args slice is still empty — meaning no virtio-net device flags were generated at all. In practice this occurs when the config somehow yields no network devices (no default usernet path taken and no networks entries resolved), so krunkit would boot with no NIC.

Source

Thrown at pkg/driver/krunkit/krunkit_darwin_arm64.go:176

					return nil, err
				}
				mac = nw.MACAddress
			default:
				return nil, fmt.Errorf("invalid network spec %+v", nw)
			}
		} else if nw.Socket != "" {
			sock = nw.Socket
			mac = nw.MACAddress
		} else {
			return nil, fmt.Errorf("invalid network spec %+v", nw)
		}

		device := fmt.Sprintf("virtio-net,type=unixstream,path=%s,mac=%s", sock, mac)
		args = append(args, "--device", device)
	}

	if len(args) == 0 {
		return args, errors.New("no socket_vmnet networks defined")
	}

	return args, nil
}

func startUsernet(ctx context.Context, inst *limatype.Instance) (*usernet.Client, context.CancelFunc, error) {
	if firstUsernetIndex := limayaml.FirstUsernetIndex(inst.Config); firstUsernetIndex != -1 {
		return usernet.NewClientByName(inst.Config.Networks[firstUsernetIndex].Lima), nil, nil
	}
	// Start a in-process gvisor-tap-vsock
	endpointSock, err := usernet.SockWithDirectory(inst.Dir, "", usernet.EndpointSock)
	if err != nil {
		return nil, nil, err
	}
	krunkitSock, err := usernet.SockWithDirectory(inst.Dir, "", usernet.FDSock)
	if err != nil {
		return nil, nil, err
	}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Add a network entry to lima.yaml, e.g. `networks: [{lima: user-v2}]`, so at least one NIC is configured.
  2. Restore the default config (`limactl start template://default`) if the instance config was heavily hand-edited.
  3. If you believe the config is valid, report a bug to Lima — this indicates the krunkit driver's default usernet path failed to append its device silently (e.g. PassFDToUnix path change).
  4. Check Lima version; upgrade in case the default-network handling for krunkit changed.

Example fix

# before
networks: []
# after
networks:
  - lima: user-v2
Defensive patterns

Strategy: validation

Validate before calling

# Shell: ensure at least one usable network before krunkit start
count=$(yq '(.networks // []) | length' lima.yaml)
[ "$count" -gt 0 ] || yq '.networks += [{"lima": "user-v2"}]' -i lima.yaml

Type guard

func hasUsableNetwork(cfg Config) bool {
    if len(cfg.Networks) == 0 { return false }
    for _, nw := range cfg.Networks {
        if nw.Lima == "user-v2" || nw.Lima == "shared" || nw.Lima == "bridged" || nw.Socket != "" {
            return true
        }
    }
    return false
}

Try / catch

if err := inst.Start(ctx); err != nil {
    if strings.Contains(err.Error(), "no socket_vmnet networks defined") {
        log.Error("no network devices configured; add networks: [{lima: user-v2}]")
    }
    return err
}

Prevention

When it happens

Trigger: Starting a krunkit instance where FirstUsernetIndex == -1 path also produced no args and inst.Networks is empty/produced nothing — a degenerate config where the default gvisor usernet device was not added and no socket_vmnet networks exist.

Common situations: Deeply modified instance config with networks stripped out while the driver still requires at least one network device; driver-level invariant check rather than a user-actionable config state in normal flows.

Related errors


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