From 2df31300e3632ed799ba08099375ddd130b39af3 Mon Sep 17 00:00:00 2001 From: KAI Maintainer Date: Tue, 9 Jun 2026 11:27:13 -0700 Subject: [PATCH] fix(installer): improve error message when port 4000 is already in use Replace .unwrap() on TcpListener::bind with .with_context() so users see a clear message about the port conflict instead of a panic. Fixes #906 --- installer/src/tplink.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/installer/src/tplink.rs b/installer/src/tplink.rs index 0fcda3a..18d38b7 100644 --- a/installer/src/tplink.rs +++ b/installer/src/tplink.rs @@ -346,9 +346,13 @@ async fn tplink_launch_telnet_v5(admin_ip: &str) -> Result<(), Error> { admin_ip: admin_ip.to_owned(), }); - let listener = tokio::net::TcpListener::bind("127.0.0.1:4000") + let bind_addr = "127.0.0.1:4000"; + let listener = tokio::net::TcpListener::bind(bind_addr) .await - .unwrap(); + .with_context(|| format!( + "Failed to bind to {bind_addr}. Is another process using this port?\n\ + Try closing any application that might be listening on port 4000 and rerun the installer." + ))?; println!("Listening on http://{}", listener.local_addr().unwrap()); println!("Please open above URL in your browser and log into the router to continue.");