{"record":{"id":"47f519a196ed6dbc","repo":"lima-vm/lima","slug":"field-s-hostsocket-must-be-less-than-unix-path","errorCode":null,"errorMessage":"field `%s.hostSocket` must be less than UNIX_PATH_MAX=%d characters, but is %d","messagePattern":"field `(.+?)\\.hostSocket` must be less than UNIX_PATH_MAX=(.+?) characters, but is (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limayaml/validate.go","lineNumber":373,"sourceCode":"\t\t\t}\n\t\t\tif rule.HostSocket == \"\" && rule.HostPortRange[1]-rule.HostPortRange[0] > 0 {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.guestSocket` can only be mapped to a single port or socket. not a range\", field))\n\t\t\t}\n\t\t}\n\t\tif rule.HostSocket != \"\" {\n\t\t\tif !filepath.IsAbs(rule.HostSocket) {\n\t\t\t\t// should be unreachable because FillDefault() will prepend the instance directory to relative names\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostSocket` must be an absolute path, but is %#q\", field, rule.HostSocket))\n\t\t\t}\n\t\t\tif rule.GuestSocket == \"\" && rule.GuestPortRange[1]-rule.GuestPortRange[0] > 0 {\n\t\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostSocket` can only be mapped from a single port or socket. not a range\", field))\n\t\t\t}\n\t\t} else if rule.GuestPortRange[1]-rule.GuestPortRange[0] != rule.HostPortRange[1]-rule.HostPortRange[0] {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostPortRange` must specify the same number of ports as field `%s.guestPortRange`\", field, field))\n\t\t}\n\n\t\tif len(rule.HostSocket) >= osutil.UnixPathMax {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.hostSocket` must be less than UNIX_PATH_MAX=%d characters, but is %d\",\n\t\t\t\tfield, osutil.UnixPathMax, len(rule.HostSocket)))\n\t\t}\n\t\tswitch rule.Proto {\n\t\tcase limatype.ProtoTCP, limatype.ProtoUDP, limatype.ProtoAny:\n\t\tdefault:\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.proto` must be %#q, %#q, or %#q\", field, limatype.ProtoTCP, limatype.ProtoUDP, limatype.ProtoAny))\n\t\t}\n\t\tif rule.Reverse && rule.GuestSocket == \"\" {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.reverse` must be %t\", field, false))\n\t\t}\n\t\tif rule.Reverse && rule.HostSocket == \"\" {\n\t\t\terrs = errors.Join(errs, fmt.Errorf(\"field `%s.reverse` must be %t\", field, false))\n\t\t}\n\t\t// Not validating that the various GuestPortRanges and HostPortRanges are not overlapping. Rules will be\n\t\t// processed sequentially and the first matching rule for a guest port determines forwarding behavior.\n\t}\n\tfor i, rule := range y.CopyToHost {\n\t\tfield := fmt.Sprintf(\"CopyToHost[%d]\", i)","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limayaml/validate.go#L355-L391","documentation":"Unix domain socket paths are limited to 104/108 bytes (UNIX_PATH_MAX, per osutil.UnixPathMax). A hostSocket longer than that cannot be bound by the hostagent forwarding listener, so validation fails early with the actual length reported.","triggerScenarios":"Validate on a LimaYAML where len(portForwards[i].HostSocket) >= osutil.UnixPathMax — typically deep instance directories like ~/.lima/very-long-instance-name/vz/... plus a long socket name.","commonSituations":"Long LIMA_HOME paths on macOS/Linux; long instance names compounded with subdirectory paths; nested container runtimes placing sockets under very long prefixes.","solutions":["Shorten the hostSocket path, e.g. place the socket in /tmp with a short name","Shorten the instance name or LIMA_HOME directory so the derived socket path fits","Use a symlink-free short parent directory for the socket"],"exampleFix":"// before\nportForwards:\n  - guestPort: 80\n    hostSocket: /Users/averylongusername/Library/Application Support/lima/very-long-instance-name/sock\n// after\nportForwards:\n  - guestPort: 80\n    hostSocket: /tmp/lv80.sock","handlingStrategy":"validation","validationCode":"import \"github.com/lima-vm/lima/v2/pkg/osutil\"\n\nfor i, rule := range y.PortForwards {\n  if len(rule.HostSocket) >= osutil.UnixPathMax {\n    return fmt.Errorf(\"portForwards[%d]: hostSocket too long (%d >= %d)\", i, len(rule.HostSocket), osutil.UnixPathMax)\n  }\n}","typeGuard":"func socketPathFits(p string) bool { return p == \"\" || len(p) < osutil.UnixPathMax }","tryCatchPattern":"if err := limayaml.Validate(y, false); err != nil {\n  if strings.Contains(err.Error(), \"UNIX_PATH_MAX\") {\n    // shorten hostSocket or move it to a short directory like /tmp\n  }\n}","preventionTips":["Keep instance names and LIMA_HOME short","Place host sockets in short directories like /tmp","Check path length when templates compute socket paths from instance dirs"],"tags":["lima","port-forwarding","unix-socket","path-length"],"backgroundTag":"unix-socket-path-too-long","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}