{"record":{"id":"d11997619f07d00f","repo":"lima-vm/lima","slug":"port-not-found-in-q","errorCode":null,"errorMessage":"port not found in %#q","messagePattern":"port not found in %#q","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/store/instance.go","lineNumber":262,"sourceCode":"\t\t\treturn 0, err\n\t\t}\n\t}\n\treturn pid, nil\n}\n\n// sshPortFromConfig extracts the SSH port from an ssh config file.\nfunc sshPortFromConfig(configPath string) (int, error) {\n\tb, err := os.ReadFile(configPath)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tfor line := range strings.SplitSeq(string(b), \"\\n\") {\n\t\tline = strings.TrimSpace(line)\n\t\tif port, ok := strings.CutPrefix(line, \"Port \"); ok {\n\t\t\treturn strconv.Atoi(port)\n\t\t}\n\t}\n\treturn 0, fmt.Errorf(\"port not found in %#q\", configPath)\n}\n\ntype FormatData struct {\n\tlimatype.Instance `yaml:\",inline\"`\n\n\t// Using these host attributes is deprecated; they will be removed in Lima 3.0\n\t// The values are available from `limactl info` as hostOS, hostArch, limaHome, and identifyFile.\n\tHostOS       string `json:\"HostOS\" yaml:\"HostOS\" lima:\"deprecated\"`\n\tHostArch     string `json:\"HostArch\" yaml:\"HostArch\" lima:\"deprecated\"`\n\tLimaHome     string `json:\"LimaHome\" yaml:\"LimaHome\" lima:\"deprecated\"`\n\tIdentityFile string `json:\"IdentityFile\" yaml:\"IdentityFile\" lima:\"deprecated\"`\n}\n\nvar FormatHelp = \"\\n\" +\n\t\"These functions are available to go templates:\\n\\n\" +\n\ttextutil.IndentString(2,\n\t\tstrings.Join(textutil.FuncHelp, \"\\n\")+\"\\n\")\n","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/store/instance.go#L244-L280","documentation":"sshPortFromConfig scans the instance's ssh.config line by line for a line starting with 'Port ' and returns its numeric value. If no such line exists, it returns 'port not found in <configPath>'. Callers treat ErrNotExist as benign but this error is surfaced on the instance.","triggerScenarios":"The ssh.config file exists but contains no line with the 'Port ' prefix (note: requires exactly 'Port ' at line start after trimming, not 'Port\\t' without space or lowercase 'port').","commonSituations":"User hand-edited or regenerated ssh.config without a Port directive; port line written with a tab instead of a space; config truncated to only Host/HostName lines after a bad restore.","solutions":["Add or fix a 'Port <number>' line in ~/.lima/<inst>/ssh.config (single space after 'Port')","Delete ssh.config and restart the instance so Lima rewrites it","Check the actual forwarded port via `limactl list` / hostagent Info and set it manually if needed","Recreate the instance if config regeneration is not possible"],"exampleFix":"// before: ssh.config missing port line\nHost lima-myvm\n  HostName 127.0.0.1\n// after\nHost lima-myvm\n  HostName 127.0.0.1\n  Port 49153","handlingStrategy":"validation","validationCode":"b, err := os.ReadFile(filepath.Join(instDir, \"ssh.config\"))\nif err == nil && !strings.Contains(string(b), \"Port \") {\n    // missing Port directive: regenerate or fix ssh.config before Inspect\n}","typeGuard":null,"tryCatchPattern":"inst, err := store.Inspect(ctx, instDir)\nfor _, e := range inst.Errors {\n    if strings.Contains(e.Error(), \"port not found\") {\n        // regenerate ssh.config by stopping and starting the instance\n    }\n}","preventionTips":["Let Lima own ssh.config; do not rewrite it by hand","Keep the exact 'Port <n>' directive format (leading 'Port ' with a space)","After restoring instance dirs from backup, restart the instance to regenerate derived files"],"tags":["lima","ssh","config","port"],"backgroundTag":"missing-config-field","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}