Tamir Dresher

Hi there, I'm Tamir Dresher!

I live and breath software development since 2005 and work as Chief Architect at Clarizen

How I fixed the error 'an attempt was made to access a socket in a way forbidden by its access permissions' on my machine

In the last two days i was fighting the werid situation where i couldn’t bind to a specific port on my machine. All the other ports were fine, but this specific one was just blocked and didn’t matter what applicaiton i ran to try to bind to it.

Here are the steps i did until i found the reason:

  1. make sure it’s not the antivirus or any other security application
  2. make sure no other process is using this port by running netstat or TCPView
    netstat -ano | wsl grep "<port>"
  3. if anything shows up, kill the process that owns the port
    kill <PID>
  4. if this didn’t work, reset the machine TCP/IP stack
    netsh int ip reset
  5. if you find that anything is was blocked and the message “Access is denied” is shown, follow the steps listed here and run the previous step again
  6. Reset the machine