Dotnet Run command gives : Unable to bind to http://localhost:5000 on the IPv4 loopback interface, One or more errors occurred. (Error -4092 EACCES permission denied)
Dotnet Run command gives : Unable to bind to http://localhost:5000 on the IPv4 loopback interface, One or more errors occurred. (Error -4092 EACCES permission denied).
Here is the complete output:
PS C:\VS2015Samples\SecondCoreApi\src\SecondCoreApi> dotnet run
Project SecondCoreApi (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to bind to http://localhost:5000 on the IPv4 loopback interface.
System.AggregateException: One or more errors occurred. (Error -4092 EACCES permission denied) ---> Microsoft.AspNetCore
.Server.Kestrel.Internal.Networking.UvException: Error -4092 EACCES permission denied
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.Check(Int32 statusCode)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind(UvTcpHandle handle, SockAddr& addr, Int32 f
lags)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address)
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)
---> (Inner Exception #0) Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -4092 EACCES permis
sion denied
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.Check(Int32 statusCode)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind(UvTcpHandle handle, SockAddr& addr, Int32 f
lags)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address)
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()<---
Hosting environment: Production Content root path: C:\VS2015Samples\SecondCoreApi\src\SecondCoreApi\bin\Debug\netcoreapp1.0 Now listening on: http://localhost:5000
But i am not able run the api. Any idea why ?
localhost resolves to 127.0.0.1 and ::1. It sounds like 127.0.0.1:5000 was already taken by another app, but [::1]:5000 succeeded. netstat.exe -a -b should show you the status of that port.
I do went and changed the launchurl to "http://localhost:6020/api/values" in launchSettings.json , inspite of that it is trying to run app on port 5000. Where else should i change the port number?
VS 2017? The parameter was renamed to applicationurl. https://github.com/aspnet/KestrelHttpServer/issues/1604
Its VS 2017 update3 not VS 2017
I ran the netstat command and there is nothing listing on 127.0.0.1:5000.
[svchost.exe] TCP 127.0.0.1:60997 PCFTEST-DD7:0 LISTENING [dotnet.exe] TCP 127.0.0.1:60997 PCFTEST-DD7:60998 ESTABLISHED [dotnet.exe] TCP 127.0.0.1:60998 PCFTEST-DD7:60997 ESTABLISHED [devenv.exe] TCP 127.0.0.1:61107 PCFTEST-DD7:0 LISTENING [VBoxHeadless.exe] TCP 127.0.0.1:61294 PCFTEST-DD7:0 LISTENING [dotnet.exe] TCP 127.0.0.1:61294 PCFTEST-DD7:61295 ESTABLISHED [dotnet.exe] TCP 127.0.0.1:61295 PCFTEST-DD7:61294 ESTABLISHED
@halter73 @cesarbs
Vs 2015 update3 you mean? That never passed launchurl through to the console. You can set ASPNETCORE_URLS in the environment variables section, or call UseUrls in Program.Main.
sorry typo error , Yes its VS 2015 Community edition version 14.0.25431.01 Update 3.
Cool thank you Tratcher, when i added UseUrls in Program.Main it worked. But its still interesting why, even though there is nothing listening on port 5000 it was not able to run.
@cesarbs is the error expected for port conflict?
Hi, I am able to run dot net core webapi using dotnet run command, but i am not able to debug it using F5. I have kept break points in Program.cs , startup.cs and inside controller. Break point hits both program.cs and startup.cs but it never hits the controller. Any idea why? I am new to dot net core so can you some one please let me know if i am missing something here ?
If something was already bound to that port, you'd get an EADDRINUSE.
@gsainagendraprasad Can you check that it fails to bind to the IPv4 loopback on other ports? Try something like 5002 or 8080. Also try a high port number like 50000.
Thank you @cesarbs. I am not getting any error like EADDRINUSE, i got this before and i changed my port numbers. To me this seems something to do with IISExpress. I may be totally wrong here but when i changed the profile from IISExpress to my application name in Properties/Debug and specified launch url it worked. Now i am able to debug my controller.
I just resolved this error (for anyone later reading this thread) by ending a bunch of processes / anything that could possibly be listening on the same port. After doing that, I was able to start the project with the server listener without "Error -4092 EACCES permission denied". It is a port conflict, something else already had it bound.
I resolved the same error by changing the port number in the Web API launchSettings.json file.
In my case, the issue was similar to @skynode, however I had to actually remove the port numbers entirely. I removed the applicationUrl line in launchSettings.json
We periodically close 'discussion' issues that have not been updated in a long period of time.
We apologize if this causes any inconvenience. We ask that if you are still encountering an issue, please log a new issue with updated information and we will investigate.