LGUG2Z/komorebi · critical

could not start tcp server

Error message

could not start tcp server

What it means

listen_for_commands_tcp binds a TcpListener on 0.0.0.0:{port} (default 43663) and panics with this message if bind() fails. Common bind failures: the port is already in use by another komorebi instance or another program, or binding is blocked by permissions/policy.

Source

Thrown at komorebi/src/process_command.rs:149

                        }
                        Err(error) => {
                            tracing::error!("{}", error);
                            break;
                        }
                    }
                }
            })
            .join();

            tracing::error!("restarting failed thread");
        }
    });
}

#[tracing::instrument]
pub fn listen_for_commands_tcp(wm: Arc<Mutex<WindowManager>>, port: usize) {
    let listener =
        TcpListener::bind(format!("0.0.0.0:{port}")).expect("could not start tcp server");

    std::thread::spawn(move || {
        tracing::info!("listening on 0.0.0.0:43663");
        for client in listener.incoming() {
            match client {
                Ok(mut stream) => {
                    net2::TcpStreamExt::set_keepalive(&stream, Some(Duration::from_secs(30)))
                        .expect("TCP keepalive should be set");

                    let addr = stream
                        .peer_addr()
                        .expect("incoming connection should have an address")
                        .to_string();

                    let mut connections = TCP_CONNECTIONS.lock();

                    connections.insert(
                        addr.clone(),

View on GitHub (pinned to e0709f02bf)

Solutions

  1. Kill the existing komorebi.exe or other process using port 43663 (netstat -ano | findstr 43663)
  2. Start komorebi with a different --port via CLI option
  3. Remove duplicate autostart entries so only one instance launches
  4. Check firewall/security software that may block socket binding

Example fix

// before
let listener = TcpListener::bind(format!("0.0.0.0:{port}")).expect("could not start tcp server");
// after
let listener = match TcpListener::bind(format!("0.0.0.0:{port}")) {
    Ok(l) => l,
    Err(e) => { tracing::error!("could not start tcp server on {port}: {e}"); return; }
};
Defensive patterns

Strategy: validation

Validate before calling

// PowerShell: ensure port 43663 is free before starting
netstat -ano | Select-String ':43663 ' ; if ($?) { throw "port 43663 in use" }

Prevention

When it happens

Trigger: Calling main while a second komorebi instance is running, any other process listening on port 43663, or an OS-level restriction preventing the bind.

Common situations: Starting komorebi twice (e.g. duplicate autostart entries); port 43663 occupied by another app; leftover zombie komorebi.exe after a crash.

Related errors


AI-assisted analysis of LGUG2Z/komorebi@e0709f02bf (2026-09-06). Data as JSON: /api/errors/9e49336864fa5557. Report an issue: GitHub.