{"record":{"id":"2325694a08ac7b89","repo":"juicedata/juicefs","slug":"no-valid-pprof-port-found","errorCode":null,"errorMessage":"no valid pprof port found","messagePattern":"no valid pprof port found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/debug.go","lineNumber":217,"sourceCode":"\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\n\t\t\t}()\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif port >= 6060 && port <= 6099 && port > listenPort {\n\t\t\t\tif err := checkPort(port, amp); err == nil {\n\t\t\t\t\tlistenPort = port\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t}\n\n\tif listenPort == -1 {\n\t\treturn 0, fmt.Errorf(\"no valid pprof port found\")\n\t}\n\treturn listenPort, nil\n}\n\nfunc getRequest(url string, timeout time.Duration) ([]byte, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\treq, err := http.NewRequestWithContext(ctx, \"GET\", url, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating GET request: %v\", err)\n\t}\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error GET request: %v\", err)\n\t}\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"error GET request, status code %d\", resp.StatusCode)\n\t}","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/debug.go#L199-L235","documentation":"getPprofPort scans every LISTEN line from lsof for the mount process, keeping only ports in the pprof range 6060-6099 that pass checkPort (the /debug/pprof/cmdline endpoint must be alive and its cmdline must contain the mount point). If no port survives, listenPort stays -1 and the function returns this error, meaning `juicefs debug` cannot locate the running client's pprof endpoint.","triggerScenarios":"Called by collectPprof when: the JuiceFS client was built/started without net/http/pprof listening (no 6060 port); pprof binds outside 6060-6099; all candidate ports fail checkPort (mount-point mismatch in cmdline, pprof unreachable); or the lsof output was empty/unparseable.","commonSituations":"Mounting with `--no-pprof`-style restrictions or a firewalled/loopback-restricted pprof; the process is running in a different network namespace or container than where `juicefs debug` is run; `--debug-agent` config sets an out-of-range port; stale lsof (root privileges missing so lines are filtered).","solutions":["Confirm the mount process actually listens on pprof: `lsof -i -nP -p <pid> | grep LISTEN` and look for 6060-6099.","Run `curl http://localhost:6060/debug/pprof/cmdline?debug=1` and verify the output contains the exact mount point string passed to `juicefs debug` (checkPort requires an exact field match).","Run `juicefs debug` in the same network namespace/container as the mount process (e.g. `nsenter` or `docker exec`).","Re-mount with pprof enabled (default behavior; check that the binary is not built/launched with pprof disabled) or set `--debug-agent` in the config so cfg.Port.DebugAgent supplies the port directly.","If lsof requires elevated privileges, re-run with sudo so LISTEN lines are not filtered out."],"exampleFix":"// before (mount without pprof reachable)\njuicefs mount redis://host:6379/1 /mnt/jfs\n// after (verify/enable pprof, then debug)\ncurl -s http://localhost:6060/debug/pprof/cmdline?debug=1 | tr '\\0' ' '   # must contain /mnt/jfs\njuicefs debug /mnt/jfs","handlingStrategy":"fallback","validationCode":"out, _ := exec.Command(\"/bin/sh\", \"-c\", fmt.Sprintf(\"lsof -i -nP -p %d | grep LISTEN\", pid)).CombinedOutput()\nre := regexp.MustCompile(`:(60[6-9]\\d)\\s`) // 6060-6099\nif !re.Match(out) {\n    return errors.New(\"no pprof listener in 6060-6099 for this pid; is pprof enabled?\")\n}","typeGuard":"func hasPprofPort(listenPorts []int) bool {\n    for _, p := range listenPorts {\n        if p >= 6060 && p <= 6099 { return true }\n    }\n    return false\n}","tryCatchPattern":"if port, err := getPprofPort(pid, amp); err != nil {\n    logger.Warnf(\"pprof collection skipped: %v\", err) // degrade gracefully, continue debug collection\n    return nil\n}","preventionTips":["Mount with pprof enabled (default) and don't occupy 6060-6099 with other services.","Run `juicefs debug` in the same host/network namespace/container as the mount process.","Pre-verify with `curl http://localhost:6060/debug/pprof/cmdline?debug=1` before running debug.","Ensure lsof is installed and run with sufficient privileges so LISTEN lines aren't filtered."],"tags":["pprof","diagnostics","port-discovery"],"backgroundTag":"resource-not-found","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}