C#C
C#12mo ago
VoidPointer

✅ Recurring Access to Socket Forbidden by Access Permissions

I am plagued by this exception when trying to start up multiple ASP.NET web APIs in Visual Studio.
System.IO.IOException
HResult=0x80131620
Message=Failed to bind to address https://localhost:44330.
Source=Microsoft.AspNetCore.Server.Kestrel.Core
StackTrace:
...
Inner Exception 1:
AggregateException: One or more errors occurred. (An attempt was made to access a socket in a way forbidden by its access permissions.) (An attempt was made to access a socket in a way forbidden by its access permissions.)

Inner Exception 2:
SocketException: An attempt was made to access a socket in a way forbidden by its access permissions.

I'm using the VS multi-project startup config, and all my starting apps are configured to use a Dev.Debug launchsettings profile. None of this profiles use, in this case 44330, and the SslPort in IisSettings is set to 0 for all of them, as a desperate measure.

If I check the administered exclusions using netsh interface ipv4 show excludedportrange protocol=tcp while VS is open, my ports are there and excluded, but as soon as I close VS, the same command only shows a tiny list of excluded ports.

When I start VS the ports aren't excluded. It's only after I try the multi-project startup that they get added to the excluded range. Starting just one project results in these ports being added to the excluded range, despite that single project not having any launch profiles configured for them:
     40337       40337
     40339       40339
     44390       44390
     44399       44399
Was this page helpful?