ErrorKind::AddrNotAvailable
RustERRORNotableNetwork
Address not available
Quick Answer
Bind to 0.0.0.0 (all interfaces) or verify the specific IP is assigned to this host.
What this means
The requested local address is not available on this machine (e.g. binding to a non-existent IP).
Why it happens
- 1Binding to an IP that is not assigned to any local interface
- 2Interface is down or not yet configured
Fix
Bind to all interfaces
Bind to all interfaces
use std::net::TcpListener;
// Instead of a specific IP that may not exist:
let listener = TcpListener::bind("0.0.0.0:8080")?;Why this works
0.0.0.0 matches any local interface, avoiding EADDRNOTAVAIL.
Code examples
Triggerrust
TcpListener::bind("192.168.99.99:8080")?; // IP not on hostSame error in other languages
Sources
Official documentation ↗
Rust std::io
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev