{"record":{"id":"04e5f02e56b9f653","repo":"juicedata/juicefs","slug":"listen-s","errorCode":null,"errorMessage":"listen: %s","messagePattern":"listen: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/sync/cluster.go","lineNumber":348,"sourceCode":"\t\t\t}\n\t\t\taddr = ip + addr\n\t\t}\n\t} else {\n\t\tip, err := utils.GetLocalIp(net.JoinHostPort(u.Host, \"22\"))\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"not found local ip: %s\", err)\n\t\t}\n\t\tlogger.Debugf(\"Use local ip %s\", ip)\n\t\taddr = ip\n\t}\n\n\tif !strings.Contains(addr, \":\") {\n\t\taddr += \":\"\n\t}\n\n\tl, err := net.Listen(\"tcp\", addr)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"listen: %s\", err)\n\t}\n\tlogger.Infof(\"Listen at %s\", l.Addr())\n\tgo func() { _ = http.Serve(l, mux) }()\n\treturn l.Addr().String(), nil\n}\n\nfunc findSelfPath() (string, error) {\n\tprogram := os.Args[0]\n\tif strings.Contains(program, \"/\") {\n\t\tpath, err := filepath.Abs(program)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"resolve path %s: %s\", program, err)\n\t\t}\n\t\treturn path, nil\n\t}\n\tfor _, searchPath := range strings.Split(os.Getenv(\"PATH\"), \":\") {\n\t\tif searchPath != \"\" {\n\t\t\tp := filepath.Join(searchPath, program)","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/sync/cluster.go#L330-L366","documentation":"After computing the listen address, startManager calls net.Listen(\"tcp\", addr). This error wraps a listener creation failure, meaning the manager could not bind the TCP port — typically because the port is already in use, the address is not assignable to any interface, or permission is denied for privileged ports.","triggerScenarios":"startManager binds the resolved addr and net.Listen fails: another process holds the port (address already in use), binding to an IP not present on the host, using a privileged port (<1024) as non-root, or port range exhausted.","commonSituations":"Previous sync manager still running and holding the port; --manager-addr pointing to the wrong host IP; using port 80/443 without root; docker/k8s port conflicts.","solutions":["Free the port: find and stop the process holding it (ss -ltnp / lsof -i :PORT) or pick a different --manager-addr port","Use a port >1024 or run with appropriate privileges if binding a privileged port","Make sure the IP in --manager-addr exists on the manager host (use 0.0.0.0 or the correct interface IP)"],"exampleFix":"// before\n--manager-addr 10.0.0.5:8080   # port taken\n// after\n--manager-addr 10.0.0.5:18080","handlingStrategy":"validation","validationCode":"// Check port availability before starting the manager\nif l, err := net.Listen(\"tcp\", addr); err != nil {\n\treturn fmt.Errorf(\"port %s unavailable: %w\", addr, err)\n} else {\n\tl.Close()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick a free, high (>1024) port for --manager-addr","Check for stale manager processes before restarting sync (ss -ltnp)","Bind to an IP that actually exists on the manager host, or 0.0.0.0"],"tags":["network","tcp","listen","port-conflict"],"backgroundTag":"address-already-in-use","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"}