Kestrelhttpserver: EADDRINUSE address already in use

Created on 6 Aug 2016  路  9Comments  路  Source: aspnet/KestrelHttpServer

Hello Microsoft, I've just tried to launch ASP.NET application sample from official docs using Ubuntu Linux 14.04 subsystem for Windows 10 and came across the following issue with Kestrel:

Unhandled Exception: System.AggregateException: One or more errors occurred. (Error -98 EADDRINUSE address already in use) ---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -98 EADDRINUSE address already in use
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.Check(Int32 statusCode)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.GetSockIPEndPoint()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListenerPrimary.CreateListenSocket()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<>c.<StartAsync>b__6_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary.<StartAsync>d__11.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(ServerAddress address)
   at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at aspnetcoreapp.Program.Main(String[] args)

Here's app sources and some compiled binaries for it:
Bloge.zip

Windows 10 1607 (Build 14393.10)
Linux Ubuntu 14.04.5 LTS

Most helpful comment

Kill all the tasks with .net and Visual Studio and this should work. For Mac users, go to Activity Monitor -> dotnet ->Memory -> Quit

All 9 comments

The port you tried to listen on was already in use. Did you try another one?

Yes. Changing port number using UseUrls() method had no effect on it. Default port number (5000) did't work too.

I can repro. Investigating.

@fanadd You're hitting a known issue: https://github.com/Microsoft/BashOnWindows/issues/68

You can work around it by listening on 127.0.0.1 or [::1] (but not both - fails with the same error).

@cesarbs How do I make the change and listen to 127.0.0.1 please?

dotnet run --server.urls http://127.0.0.1:5000

@rexebin Just pass it to UseUrls when building the host, along with the port you want to bind to:

var host = new WebHostBuilder()
    ...
    .UseUrls("http://127.0.0.1:8080", ...)
    ...

Tak a look in Task Explorrer if there is not any other instance of your project running. If so, end it and try again.

Kill all the tasks with .net and Visual Studio and this should work. For Mac users, go to Activity Monitor -> dotnet ->Memory -> Quit

Was this page helpful?
0 / 5 - 0 ratings