{"record":{"id":"3c6376bab725c4a2","repo":"pbakaus/impeccable","slug":"error-no-free-port","errorCode":null,"errorMessage":"Error: no free port\n","messagePattern":"Error: no free port\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/live/src/live_server.rs","lineNumber":292,"sourceCode":"            match TcpListener::bind((\"127.0.0.1\", port)) {\n                Ok(l) => l,\n                Err(e) => {\n                    io.err(&format!(\n                        \"Error: listen EADDRINUSE: address already in use 127.0.0.1:{} ({})\\n\",\n                        port, e\n                    ));\n                    return 1;\n                }\n            }\n        }\n        None => {\n            let mut port: u16 = 8400;\n            loop {\n                match TcpListener::bind((\"127.0.0.1\", port)) {\n                    Ok(l) => break l,\n                    Err(_) => {\n                        if port == u16::MAX {\n                            io.err(\"Error: no free port\\n\");\n                            return 1;\n                        }\n                        port += 1;\n                    }\n                }\n            }\n        }\n    };\n    let port = listener.local_addr().map(|a| a.port()).unwrap_or(0) as i64;\n\n    // Annotation session dir\n    let annot_root = live_annotations_dir(&cwd, &env);\n    let _ = std::fs::create_dir_all(&annot_root);\n    let session_dir = mkdtemp(&jsp::join(&[&annot_root, \"session-\"]));\n\n    {\n        let mut st = lock(&shared);\n        st.port = port;","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/live/src/live_server.rs#L274-L310","documentation":"Without an explicit `--port`, the live server auto-scans upward from port 8400, incrementing on each failed bind. If every port through u16::MAX is exhausted, it prints this message and exits 1. It indicates the fallback port allocator could not find any bindable port — in practice this signals blocked binds rather than genuine port exhaustion.","triggerScenarios":"Starting `live-server` without `--port` where the loop `TcpListener::bind((\"127.0.0.1\", port))` fails for every port from 8400 through 65535, hitting the `port == u16::MAX` guard.","commonSituations":"A sandbox or security policy (seccomp/SELinux) rejecting every loopback bind, which the scan misreads as 'port in use'; a system leaking thousands of stuck listeners; restricted containers where socket bind is disallowed entirely.","solutions":["Check whether binds are blocked at the OS level (sandbox/seccomp/SELinux) — run the same start outside the sandbox.","Inspect system listener count (`ss -ltn | wc -l`); close lingering listeners or restart the network namespace if thousands of sockets are stuck.","Grant the container/user permission to bind loopback ports, or run the live server on the host."],"exampleFix":"// before\n$ impeccable live-server\nError: no free port\n// after\n$ ss -ltn | wc -l            # inspect listener count\n$ impeccable live-server     # run where loopback bind is permitted","handlingStrategy":"fallback","validationCode":"// sanity-check that loopback binds are permitted at all before starting\npython3 -c \"import socket; s=socket.socket(); s.bind(('127.0.0.1',0)); s.close()\" || { echo 'loopback bind blocked'; exit 2; }","typeGuard":null,"tryCatchPattern":"// treat 'no free port' as an environment failure, not a retry loop\ntry {\n  execSync('impeccable live-server');\n} catch (e) {\n  if (/no free port/.test(String(e.stderr))) {\n    throw new Error('loopback binds blocked or exhausted in this environment; fix sandbox/OS policy, then retry');\n  }\n  throw e;\n}","preventionTips":["Run the live server in an environment that permits loopback binds (check seccomp/SELinux/sandbox policies).","Monitor system listener counts; avoid leaking thousands of sockets.","If the scan exhausts, investigate the OS first — thousands of occupied ports nearly always indicate policy or leakage, not genuine demand."],"tags":["network","tcp","port-exhaustion"],"backgroundTag":"no-free-port","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}