nickel-org / nickel.rs

An expressjs inspired web framework for Rust

Home Page:http://nickel-org.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't start server at 127.0.0.1

Ragueel opened this issue · comments

I wasn't able to start server at 127.0.0.1 when my computer did not had connection to any network. But writing localhost seems to work. Is this design choice?

Works no me!

endpoint: format!("127.0.0.1:7021"),

I did with Wi-Fi turned off:

let mut server = Nickel::new();
server.listen("127.0.0.1:5010");

And it throws this error when : cargo run

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InitializationError(Some("Error opening a connection: Error communicating with the server: 
A socket operation was attempted to an unreachable host. (os error 10065)"))', src\libcore\result.rs:1165:5
stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized
             at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.37\src\backtrace\mod.rs:66
   1: std::sys_common::backtrace::_print_fmt
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\sys_common\backtrace.rs:76
   2: std::sys_common::backtrace::_print::{{impl}}::fmt
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\sys_common\backtrace.rs:60
   3: core::fmt::write
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libcore\fmt\mod.rs:1028
   4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\io\mod.rs:1412
   5: std::sys_common::backtrace::_print
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\sys_common\backtrace.rs:64
   6: std::sys_common::backtrace::print
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\sys_common\backtrace.rs:49
   7: std::panicking::default_hook::{{closure}}
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\panicking.rs:196
   8: std::panicking::default_hook
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\panicking.rs:210
   9: std::panicking::rust_panic_with_hook
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\panicking.rs:473
  10: std::panicking::continue_panic_fmt
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\panicking.rs:380
  11: std::panicking::rust_begin_panic
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\panicking.rs:307
  12: core::panicking::panic_fmt
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libcore\panicking.rs:84
  13: core::result::unwrap_failed
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libcore\result.rs:1165
  14: core::result::Result<nickel_postgres::middleware::PostgresMiddleware, alloc::boxed::Box<Error>>::unwrap<nickel_postgres::middleware::PostgresMiddleware,alloc::boxed::Box<Error>>
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\src\libcore\result.rs:933
  15: adbi_online::main
             at .\src\main.rs:29
  16: std::rt::lang_start::{{closure}}<()>
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\src\libstd\rt.rs:64
  17: std::rt::lang_start_internal::{{closure}}
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\rt.rs:49
  18: std::panicking::try::do_call<closure-0,i32>
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\panicking.rs:292
  19: panic_unwind::__rust_maybe_catch_panic
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libpanic_unwind\lib.rs:80
  20: std::panicking::try
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\panicking.rs:271
  21: std::panic::catch_unwind
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\panic.rs:394
  22: std::rt::lang_start_internal
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\/src\libstd\rt.rs:48
  23: std::rt::lang_start<()>
             at /rustc/032a53a06ce293571e51bbe621a5c480e8a28e95\src\libstd\rt.rs:64
  24: main
  25: invoke_main
             at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  26: __scrt_common_main_seh
             at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  27: BaseThreadInitThunk
  28: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

By the way I am on Windows.

To clarify, under Windows, with wifi off, the following fails as above:

let mut server = Nickel::new();
server.listen("127.0.0.1:5010");

but this would work?

let mut server = Nickel::new();
server.listen("localhost:5010");

This is rather puzzling. What version of windows are you using? I presume turning the wifi back on fixes this?

I found out the issue. It was one of my custom middleware that tried to access the internet and thus caused errors when I tried to register it. After removing it everything works. Sorry :)