Troubleshoot Docker EE on Windows Server 2016 (“HNS Failed with error: …”)

Ashish Singh Baghel
3 min readOct 31, 2020

Fix HNS Related errors

To fix HNS Related errors, Clean Up Windows Server 2016 Host networking configuration

Run following script provide by Microsoft in PowerShell as admin to cleanup your Windows Host (Read the instructions carefully before running this script provided by Microsoft)

(Optionally) Clean Up your host manually -
Run following commands on an administrator PowerShell console :

# MAKE SURE HOST IS NOT IN SWARM MODE
docker swarm leave --force
# removes all container networks on the system.
docker network prune -f
# removes all containers on the system.
docker container prune -f
# stop docker service
net stop docker
# clean up networking components on the container hostGet-NetNatStaticMapping | Remove-NetNatStaticMapping
Get-NetNat | Remove-NetNat
Get-ContainerNetwork | Remove-ContainerNetwork
Stop-Service hns -Force
del C:\ProgramData\Microsoft\Windows\HNS\HNS.data
Restart-Service hns -ErrorAction SilentlyContinue
# Restart host
Restart-Computer -force

Also try to clean Unwanted/Duplicate/Hidden duplicated unwanted network adapters from Device Manger (if any). Below screenshot shows good case -

If nothing works try running docker daemon in debug mode to check for the errors -

net stop docker
dockerd.exe -D

Docker on Windows Server 2016 will probably cause issues if you have third party softwares like

  • Antivirus
  • Process monitoring tools

installed on your server.

Another reason if you are facing trouble with docker on Windows Server 2016 can be your network security configuration.

Recommended antivirus exclusions for Hyper-V hosts

https://docs.microsoft.com/en-US/troubleshoot/windows-server/virtualization/antivirus-exclusions-for-hyper-v-hosts

Some links explaining Docker issues with 3rd party softwares installed on Windows Server 2016 -

Carbon Black:

Trend Micro:

Recommendation from Docker for Antivirus Softwares :

Check out this link for “Anti-Virus optimization for Windows Containers” -

Get help from #Microsoft, check out this link “Support policy for Windows containers and Docker in on-premises scenarios”.

Docker on Windows Server 2016 is officially supported by Microsoft without any additional charge.

https://docs.microsoft.com/en-us/troubleshoot/windows-server/containers/support-for-windows-containers-docker-on-premises-scenarios

--

--