{"record":{"id":"a5902fedc6d741db","repo":"juicedata/juicefs","slug":"pprof-will-be-collected-but-no-listen-port","errorCode":null,"errorMessage":"pprof will be collected, but no listen port","messagePattern":"pprof will be collected, but no listen port","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/debug.go","lineNumber":184,"sourceCode":"\t\t\t} else {\n\t\t\t\treturn port, nil\n\t\t\t}\n\t\t}\n\t}\n\n\tvar lsofArgs []string\n\tif requireRootPrivileges {\n\t\tlsofArgs = append(lsofArgs, \"sudo\")\n\t}\n\tlsofArgs = append(lsofArgs, \"/bin/sh\", \"-c\", \"lsof -i -nP | grep -v grep | grep LISTEN | grep \"+pid)\n\tret, err := exec.Command(lsofArgs[0], lsofArgs[1:]...).CombinedOutput()\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"failed to execute command `%s`: %v\", strings.Join(lsofArgs, \" \"), err)\n\t}\n\tlogger.Debugf(\"lsof output: \\n%s\", string(ret))\n\tlines := strings.Split(string(ret), \"\\n\")\n\tif len(lines) == 0 {\n\t\treturn 0, fmt.Errorf(\"pprof will be collected, but no listen port\")\n\t}\n\n\tvar listenPort = -1\n\tfor _, line := range lines {\n\t\tfields := strings.Fields(line)\n\t\tif len(fields) != 0 {\n\t\t\tport, err := func() (port int, err error) {\n\t\t\t\tdefer func() {\n\t\t\t\t\te := recover()\n\t\t\t\t\tif e != nil {\n\t\t\t\t\t\terr = fmt.Errorf(\"failed to parse listen port: %v\", e)\n\t\t\t\t\t}\n\t\t\t\t}()\n\t\t\t\tport, err = strconv.Atoi(strings.Split(fields[len(fields)-2], \":\")[1])\n\t\t\t\tif err != nil {\n\t\t\t\t\tlogger.Errorf(\"failed to parse port %v: %v\", port, err)\n\t\t\t\t}\n\t\t\t\treturn","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/debug.go#L166-L202","documentation":"After running lsof successfully, `getPprofPort` looks for a listening port in the pprof range 6060-6099; if the lsof output yields no usable port it reports \"pprof will be collected, but no listen port\". It means the target JuiceFS process is not serving its pprof debug agent. (If lines exist but no candidate passes parsing/checkPort, the related \"no valid pprof port found\" is returned at line 217.)","triggerScenarios":"Running `juicefs debug <mnt>` against a process whose config lacks a debug-agent port and whose lsof output contains no LISTEN line on ports 6060-6099, or `checkPort` rejects all candidate ports.","commonSituations":"Mount was started without the pprof/debug agent enabled; the mount is behind container/network isolation so the port isn't visible; another process squats the 6060-6099 range and checkPort fails.","solutions":["Restart the mount with the pprof debug agent enabled so it listens on 6060-6099.","Configure the DebugAgent address in the mount config (Port.DebugAgent) so lsof discovery is skipped.","Manually verify with `curl http://127.0.0.1:6060/debug/pprof/` on the host where the process runs and collect profiles there.","Free or correct the 6060-6099 port range if another service occupies it, then retry."],"exampleFix":"// before\njuicefs debug /mnt/jfs   # pprof will be collected, but no listen port\n// after: restart mount so pprof listens\njuicefs mount sqlite3://test.db /mnt/jfs --debug-agent 127.0.0.1:6060\njuicefs debug /mnt/jfs","handlingStrategy":"validation","validationCode":"curl -fsS http://127.0.0.1:6060/debug/pprof/ >/dev/null 2>&1 \\\n  && juicefs debug /mnt/jfs \\\n  || echo \"pprof agent not reachable; enable debug agent on the mount\"","typeGuard":null,"tryCatchPattern":"if err := runDebug(); err != nil {\n    if strings.Contains(err.Error(), \"listen port\") {\n        log.Printf(\"pprof agent not enabled on target; restart mount with debug agent\")\n    }\n}","preventionTips":["Keep the pprof debug agent enabled (ports 6060-6099) on production mounts.","Record the DebugAgent address in the mount config so juicefs debug can read it instead of relying on lsof.","Check that nothing else occupies the 6060-6099 range on the host."],"tags":["cli","debug","pprof","diagnostics"],"backgroundTag":"empty-result-set","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}