I'm trying to run the following code on a .NET 4.5 Console app:
var app = WebApp.Start<Startup>("http://127.0.0.1:9000/");
This works on my colleagues machines but not mine.
The exception message reads "Exception has been thrown by the target of an invocation.
" with an inner exception of "The network location cannot be reached. For information about network troubleshooting, see Windows Help
".
I have tried turning off my firewall, resetting my hosts file, no anti viruses are running, flushed my DNS and cleaned/rebuilt my solution.
Here is the stack trace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context)
at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions options)
at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options)
at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start(StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start[TStartup](StartOptions options)
at Microsoft.Owin.Hosting.WebApp.Start[TStartup](String url)
at OwinTest.Program.Main(String[] args) in C:\Temp\OwinTest\OwinTest\Program.cs:line 12
If I change the code to this it works:
var app = WebApp.Start<Startup>("http://localhost:9000/");
But the above code is not what I'm looking for.
Any ideas would be appreciated.
After a whole day of research and troubleshooting, the following command worked:
netsh http add iplisten 127.0.0.1
When I ran this in command prompt, I did not receive any errors.
Try this:
var app = WebApp.Start<Startup>("http://0.0.0.0:9000/");
0.0.0.0 should mean it's listening on all IPs...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With