16

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.

3
  • Try this article also it maybe helpful to see netstat output. appuals.com/…
    – Ed B
    Sep 26 '19 at 2:54
  • I've tried the ways mentioned in it but that don't help me to resolve the issue Sep 26 '19 at 5:10
  • 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. Sep 26 '19 at 5:40
49

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

5
  • 4
    I wish I could upvote you twice Jul 6 '20 at 7:46
  • why my block list is different?
    – liang
    Nov 2 '20 at 9:39
  • 1
    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?
    – Quarkly
    Jan 1 at 20:54
  • 4
    This is really weird. The update is dated Feb 2018, and I only come across this problem on my PC today ...
    – vidriduch
    Jan 25 at 10:59
  • 1
    Just for reference, Windows 10 20H2 has now added more restricted ports: 6452-6551, 6552-6651,6652-6751
    – Roger Far
    Mar 19 at 19:35
0

I cannot add comments,

why my block list is different? – liang Nov 2 '20 at 9:39

If an IIS website uses a port, it is shown in this list. I guess other windows services also.

2
-1

I've run into this a few times with Windows 10 on dotnet core (2.2). In my case, it tends to be after my network card driver is updated (e.g., by the Dell Support Assist app). The weird part is that only one of 3 dotnet core apps has an issue, and I have no problems with my NodeJS APIs.

A restart fixes the problem, in my case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.