EADDRINUSE address already in use #1035

Closed
fanadd opened this Issue Aug 6, 2016 · 8 comments

Projects

None yet

6 participants

@fanadd
fanadd commented Aug 6, 2016

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

@Tratcher
Member
Tratcher commented Aug 6, 2016

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

@fanadd
fanadd commented Aug 6, 2016

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

@cesarbs cesarbs self-assigned this Aug 8, 2016
@cesarbs cesarbs added the 2 - Working label Aug 8, 2016
@cesarbs
Member
cesarbs commented Aug 8, 2016

I can repro. Investigating.

@cesarbs
Member
cesarbs commented Aug 8, 2016 edited

@fanadd You're hitting a known issue: Microsoft/BashOnWindows#68

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

@cesarbs cesarbs removed the 2 - Working label Aug 8, 2016
@cesarbs cesarbs closed this Aug 8, 2016
@rexebin
rexebin commented Aug 12, 2016

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

@gregorybleiker

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

@cesarbs
Member
cesarbs commented Aug 18, 2016

@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", ...)
    ...
@skorunka

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment