Unable to start Kestrel getting 'An attempt was made to access a socket in a way forbidden by its access permissions'

19,227

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.

excludedportrange list

Share:
19,227

Related videos on Youtube

user2422044
Author by

user2422044

Updated on September 18, 2022

Comments

  • user2422044
    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

    Unable to bind to port number

    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 ports

    I’m unable to find my port number in that lists as well.

    • Ed B
      Ed B over 4 years
      Try this article also it maybe helpful to see netstat output. appuals.com/…
    • user2422044
      user2422044 over 4 years
      I've tried the ways mentioned in it but that don't help me to resolve the issue
    • user2422044
      user2422044 over 4 years
      Somewhere 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
    Richard Hauer almost 4 years
    I wish I could upvote you twice
  • liang
    liang over 3 years
    why my block list is different?
  • Quarkly
    Quarkly over 3 years
    OK. 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
    vidriduch over 3 years
    This is really weird. The update is dated Feb 2018, and I only come across this problem on my PC today ...
  • Roger Far
    Roger Far about 3 years
    Just for reference, Windows 10 20H2 has now added more restricted ports: 6452-6551, 6552-6651,6652-6751
  • Community
    Community over 2 years
    Please add further details to expand on your answer, such as working code or documentation citations.
  • Aulis Ronkainen
    Aulis Ronkainen over 2 years
    This 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
    marco6 over 2 years
    I 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
    Tiramonium over 2 years
    What 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.