Microsoft.AspNetCore.Server.Kestrel[0]Unabletostart Kestrel.System.IO.IOException:Failedtobindtoaddresshttp://localhost:51816.--->System.AggregateException:Oneormoreerrorsoccurred.(Anattemptwasmadetoaccessasocketinawayforbiddenbyitsaccesspermissions.)(Anattemptwasmadetoaccessasocketinawayforbiddenbyitsaccesspermissions.)--->System.Net.Sockets.SocketException(10013):Anattemptwasmadetoaccessasocketinawayforbiddenbyitsaccesspermissions.atSystem.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketErrorerror,StringcallerName)atSystem.Net.Sockets.Socket.DoBind(EndPointendPointSnapshot,SocketAddresssocketAddress)atSystem.Net.Sockets.Socket.Bind(EndPointlocalEP)atMicrosoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.<Bind>g__BindSocket|13_0(<>c__DisplayClass13_0&)atMicrosoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()atMicrosoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPointendpoint,CancellationTokencancellationToken)atMicrosoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TransportManager.BindAsync(EndPointendPoint,ConnectionDelegateconnectionDelegate,EndpointConfigendpointConfig)atMicrosoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<>c__DisplayClass29_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()---Endofstacktracefrompreviouslocation---atMicrosoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptionsendpoint,AddressBindContextcontext)atMicrosoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.BindAsync(AddressBindContextcontext)---Endofinnerexceptionstacktrace------>(InnerException#1) System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.atSystem.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketErrorerror,StringcallerName)atSystem.Net.Sockets.Socket.DoBind(EndPointendPointSnapshot,SocketAddresssocketAddress)atSystem.Net.Sockets.Socket.Bind(EndPointlocalEP)atMicrosoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.<Bind>g__BindSocket|13_0(<>c__DisplayClass13_0&)atMicrosoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()atMicrosoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPointendpoint,CancellationTokencancellationToken)atMicrosoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TransportManager.BindAsync(EndPointendPoint,ConnectionDelegateconnectionDelegate,EndpointConfigendpointConfig)atMicrosoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<>c__DisplayClass29_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()---Endofstacktracefrompreviouslocation---atMicrosoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptionsendpoint,AddressBindContextcontext)atMicrosoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.BindAsync(AddressBindContextcontext)
The reason is most likely due to a Windows Update that restricted access to certain ports on Windows machines. The details are here.
You can view a list of which ports are excluded from your user by running this command:
Specifically, I had an ASP.NET Core web app that previously worked fine with ports 51814 and 51815 but then suddenly wouldn’t start. Looking at the list above you can see this is in the range of 51777-51876.