TcpListener fails to bind?

I have the following (simplified) code:

use tokio::net::TcpListener;

#[tokio::main]
async fn main() {
    let listener = TcpLIstener::bind("192.168.30.106:5678").await.unwrap();
    loop {
         let (stream, _) = listener.accept().await.unwrap();
         // Now process the data
     }
}

This code runs without problem. But the thing is that I cannot connect to this server. And even worse ss -ta doesn't show anything on this port.
What might the problem be?

One of the first tools I reach for is nmap whenever I'm having issues connecting to a particular port. You would do something like nmap 192.168.30.106 and it'll scan that computer to see which ports are open.

If you can ping the machine but are unable to connect to that specific port, chances are your firewall rules are blocking things.

1 Like

Is there any reason you put 192.168.30.106 as the IP in the bind call? I would try with 0.0.0.0 instead.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.