question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to start Kestrel. System.IO.IOException: Failed to bind to address http://localhost:5000 on the IPv4 loopback interface: port already in use.

See original GitHub issue

Steps to reproduce

1 - open VSCode 2 - Load the project with Code . 2 - run the project using Dotnet watch run

Expected behavior

to make the app available http://localhost:5000

Actual behavior

Unable to start Kestrel. System.IO.IOException: Failed to bind to address http://localhost:5000 on the IPv4 loopback interface: port already in use.

Environment data

dotnet --info output:

Unable to start Kestrel.
System.IO.IOException: Failed to bind to address http://localhost:5000 on the IPv4 loopback interface: port already in use. ---> System.AggregateException: One or more errors occurred. (Error -48 EADDRINUSE address already in use) ---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -48 EADDRINUSE address already in use
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.ThrowError(Int32 statusCode)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_getsockname(UvTcpHandle handle, SockAddr& addr, Int32& namelen)
   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.<StartAsync>b__8_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary.<StartAsync>d__12.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)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)

Unhandled Exception: System.IO.IOException: Failed to bind to address http://localhost:5000 on the IPv4 loopback interface: port already in use. ---> System.AggregateException: One or more errors occurred. (Error -48 EADDRINUSEaddress already in use) ---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -48 EADDRINUSE address already in use
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.ThrowError(Int32 statusCode)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_getsockname(UvTcpHandle handle, SockAddr& addr, Int32& namelen)
   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.<StartAsync>b__8_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary.<StartAsync>d__12.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)
   --- End of inner exception stack trace ---
   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 Welocate.Program.Main(String[] args) in /Users/admin/welocate/Program.cs:line 20
watch : Exited with error code 134
watch : Waiting for a file to change before restarting dotnet...

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
asmaa3107commented, Oct 19, 2018

ok, thanks.

For others having the same issue, here is the steps:

on terminal on MAC:

1 - soft -t -I :portNumber
process ID will be display (in case the port is in use ) ex: 10872
2 - kill -9 10872 (to kill the process)

I still have the same issue Win 10??

0reactions
enginmarshallcommented, Mar 13, 2021

On Windows: I was getting this error in a .dotnet core react template application and this little change of port number helped: In launchSettings.json from: “applicationUrl”: “https://localhost:5001;http://localhost:5000”, to: “applicationUrl”: “https://localhost:7580;http://localhost:5000”,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to start Kestrel. System.IO.IOException: Failed to ...
I followed the steps from this URL to publish .NET core 2.1 web application code to Linux Centos 7 server. ... I tried...
Read more >
Failed to bind to address http://localhost:5000 on the IPv4 ...
System.IO.IOException: Failed to bind to address http://localhost:5000 on the IPv4 loopback interface: port already in use.
Read more >
ASP.NET Core: Unable to start Kestrel. An attempt was ...
I have an ASP.NET Core application running smoothly on IIS and suddenly it start throwing below error while running EXE.
Read more >
Unable to start Kestrel. System.IO.IOException: Failed to bind ...
The error message is clear: something on your machine is already listening on port 5000. 2 solutions: Find what is listening to this...
Read more >
Unable to start Kestrel getting 'An attempt was made ...
While running my Kestrel application from Visual Studio 2017 (Windows 10), I'm getting this line in my command prompt: "Unable to bind to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found