Rust rocket - binding socket

Hi guys,
I am trying to make my Rocket server to auto connect to - current IP address (only on Windows).
Everything seems to be fine but when I making cargo run I have OS error 99 like below.
> fn main()
> #[cfg(test)] mod tests;
> #[get("/")]
> fn hello() {
> "Hello, world!"
> }
> //use rocket::config::{Config, Environment};
> let cfg = rocket::config::Config::build(rocket::config::Environment::Development)
> .address(my_internet_ip::get().unwrap().to_string())
> .port(80)
> .unwrap();
> rocket::custom(cfg)
> .mount("/", routes![hello])
> .launch();


Compiling diesel v0.1.0 (/home/user/diesel-simple)
Finished dev [unoptimized + debuginfo] target(s) in 4.84s
Running target/debug/diesel
:wrench: Configured for development.
=> address:
=> port: 80
=> log: normal
=> workers: 4
=> secret key: generated
=> limits: forms = 32KiB
=> keep-alive: 5s
=> tls: disabled
:artificial_satellite: Mounting /:
=> GET / (hello)
Error: Rocket failed to bind network socket to given address/port.
thread 'main' panicked at 'Cannot assign requested address (os error 99)', /home/bbasz/.cargo/registry/src/
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

I was wondering if maybe this is because my ip4 could not be public... but if i want to build web app, based on Rust, how I can take requests from not a local network on any PC?
I am runing Rust on Ubuntu. Thank you for any help.

If you don't see the address, it should receive anything sent to your computer on port 80.

Thank you Alice, but the problem is that Rocket is not starting at all.

Port 80 is a privileged port. Try starting the server with sudo.

Thank you, I tried many ports and no success. Do I need to open ports on Ubuntu?

So OS error 99 seems to be EADDRNOTAVAIL or Cannot assign requested address, so it's not a privileged port problem (but I suspect you'd run into that as well).

You don't need to open ports in the firewall just to bind them. (Though I guess that's perhaps not true if you're using SELinux).

Can you bind and

Thank you! Yes, when I am binfing localhost or some local IP Rocket is launching. Just going public fails. Binding socket to IP. Even if I am typing my current IP by hand.

What is the output of ip a | grep

If that prints nothing, then that IP is not available to your host.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.