Unable to start Kestrel getting 'An attempt was made to access a socket in a way forbidden by its access permissions'
After Windows 10 Update KB4074588, some ports are reserved by Windows and applications cannot bind to these ports. 50067 is in the blocked range.
You can use netsh interface ipv4 show excludedportrange protocol=tcp
to list the reserved ranges.
Related videos on Youtube
user2422044
Updated on September 18, 2022Comments
-
user2422044 over 1 year
While running my Kestrel application from Visual Studio 2017 (Windows 10), I'm getting this line in my command prompt:
"Unable to bind to http://localhost:50067 on the IPv4 loopback interface: 'An attempt was made to access a socket in a way forbidden by its access permissions'."
And after that it is mentioning that
Microsoft.AspNetCore.Server.Kestrel[0] Unable to start Kestrel.
For your reference, please look at the screenshot as well
What is the reason behind it?
What I did is, check the port from the command
netstat -a
.Note -
netstat -a
in the “Command Prompt” window, and press “Enter.” The computer displays a list of all open TCP and UDP portsI’m unable to find my port number in that lists as well.
-
Ed B over 4 yearsTry this article also it maybe helpful to see netstat output. appuals.com/…
-
user2422044 over 4 yearsI've tried the ways mentioned in it but that don't help me to resolve the issue
-
user2422044 over 4 yearsSomewhere is mentioned check
netstat -o
to see where this socket is being held, and I found out that there are lots of port it is showing. But the above port number is not showing.
-
-
Richard Hauer almost 4 yearsI wish I could upvote you twice
-
liang over 3 yearswhy my block list is different?
-
Quarkly over 3 yearsOK. I see that 80 is in the excluded range. How do I remove it from the excluded ranges so that I can use port 80?
-
vidriduch over 3 yearsThis is really weird. The update is dated Feb 2018, and I only come across this problem on my PC today ...
-
Roger Far about 3 yearsJust for reference, Windows 10 20H2 has now added more restricted ports: 6452-6551, 6552-6651,6652-6751
-
Community over 2 yearsPlease add further details to expand on your answer, such as working code or documentation citations.
-
Aulis Ronkainen over 2 yearsThis does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker.
-
marco6 over 2 yearsI run in this problem now (why?!), since Visual Studio chooses by default a port in the range 61930-61940 to debug a .Net application. Seems that different teams don't speak to each others sometimest at Microsoft.
-
Tiramonium over 2 yearsWhat I meant with my previous comment is that the dynamic ports seem to have changed again in the last 3 months or so, but I can't seem to find the article for it or the change that ocurred since then. Without doing any software changes, only keeping Windows 10 up to date, new ports seem to have been reserved, with 64974, the port my API used, being among them.