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 sql-server sql-server

An attempt was made to access a socket in a way forbidden by its access permissions


I had a similar issue with Docker for Windows and Hyper-V having reserved ports for its own use- in my case, it was port 3001 that couldn't be accessed.

  • The port wasn't be used by another process- running netstat -ano | findstr 3001 in an Administrator Powershell prompt showed nothing.
  • However, netsh interface ipv4 show excludedportrange protocol=tcp showed that the port was in one of the exclusion ranges.

I was able to follow the solution described in Docker for Windows issue #3171 (Unable to bind ports: Docker-for-Windows & Hyper-V excluding but not using important port ranges):

  1. Disable Hyper-V:

    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
  2. After the required restarts, reserve the port you want so Hyper-V doesn't reserve it back:

    netsh int ipv4 add excludedportrange protocol=tcp startport=3001 numberofports=1
  3. Reenable Hyper-V:

    dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

After this, I was able to start my docker container.


Per this link:

the symptom could occur if the replication service tries to use the ports that occupied by others, or by a malfunction NIC. Please try the following steps:

  1. Restart the windows firewall service
  2. Reboot the problematic machine
  3. Restart the “TCP/IP stack”. Run CMD as administrator, type “netsh int ip reset resetlog.txt” to reset TCP/IP.
  4. Try to temporarily disable antivirus.


Just Restart-Service hns can change the ports occupied by Hyper-V. It might release the port you need.