pbakaus/impeccable · error

Error: listen EADDRINUSE: address already in use 127.0.0.1:{

Error message

Error: listen EADDRINUSE: address already in use 127.0.0.1:{port} ({err})

What it means

When the live server is started with an explicit `--port=N` argument, it binds a TcpListener to 127.0.0.1:N. If the bind fails, it prints this EADDRINUSE-style message — including the OS error text as `{err}` — and exits 1. Unlike the auto port scan, an explicit port is never silently moved.

Source

Thrown at crates/live/src/live_server.rs:277

                    removed
                ));
            }
        }
        st.restore_pending_events_from_store();
        manual_apply::prune_stale_evidence(&st);
    }

    // Port
    let port_arg = argv.iter().find(|a| a.starts_with("--port="));
    let listener = match port_arg {
        Some(a) => {
            let raw = a.splitn(2, '=').nth(1).unwrap_or("");
            let p = impeccable_core::js::parse_int(raw, 10);
            let port = if p.is_nan() { 0u16 } else { p as u16 };
            match TcpListener::bind(("127.0.0.1", port)) {
                Ok(l) => l,
                Err(e) => {
                    io.err(&format!(
                        "Error: listen EADDRINUSE: address already in use 127.0.0.1:{} ({})\n",
                        port, e
                    ));
                    return 1;
                }
            }
        }
        None => {
            let mut port: u16 = 8400;
            loop {
                match TcpListener::bind(("127.0.0.1", port)) {
                    Ok(l) => break l,
                    Err(_) => {
                        if port == u16::MAX {
                            io.err("Error: no free port\n");
                            return 1;
                        }
                        port += 1;

View on GitHub (pinned to 2bc2879276)

Solutions

  1. Pick a different --port value that is free, or omit --port to let the server auto-scan from 8400.
  2. Stop the process holding the port: `<self_cmd> live-server stop`, or `lsof -i :<port>` / `ss -ltnp` to find and kill the occupier.
  3. Read the `{err}` portion of the message to confirm it is genuinely EADDRINUSE and not a permission problem (e.g. privileged port).

Example fix

// before
$ impeccable live-server --port=8400
Error: listen EADDRINUSE: address already in use 127.0.0.1:8400 (Address already in use (os error 98))
// after
$ impeccable live-server --port=8401   # or omit --port for auto-scan
Defensive patterns

Strategy: validation

Validate before calling

// shell: verify the requested port is free before passing --port
port=8400
if [ -n "$WANTED_PORT" ]; then
  if ss -ltn "sport = :$WANTED_PORT" | grep -q LISTEN; then echo "port $WANTED_PORT busy" >&2; exit 2; fi
  PORT_ARG="--port=$WANTED_PORT"
fi
impeccable live-server $PORT_ARG

Try / catch

// on EADDRINUSE, drop the explicit port and retry with auto-scan
try {
  execSync('impeccable live-server --port=8400');
} catch (e) {
  if (/EADDRINUSE/.test(String(e.stderr))) execSync('impeccable live-server');
  else throw e;
}

Prevention

When it happens

Trigger: `live-server --port=N` (args parsed as `port=N`) where `TcpListener::bind(("127.0.0.1", port))` returns Err — another process (often a previous live server) already holds port N. Note bind errors other than EADDRINUSE also land here, with the real OS error in `{err}`.

Common situations: Passing a fixed --port that a previous live-server instance still occupies; another dev tool on the same machine using the requested port; container port mappings conflicting with the loopback bind; a non-numeric --port value parsing as NaN and falling back to port 0 handling.

Related errors


AI-assisted analysis of pbakaus/impeccable@2bc2879276 (2026-09-08). Data as JSON: /api/errors/f88215966389257e. Report an issue: GitHub.