Forum Discussion
Windows 10 1803 to 1809 Hyper-V - Cannot connect to the virtual machine
AMoeller88 That doesn't work for me, unfortunately.
Vic_U I know this is an old thread I initially started, but I had the exact same issue migrating from Windows 10 1909 to 2004.
I did come across an article with a registry fix, changing the ListenerPort dword from 2179 to 21791 under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization. After stopping/started the hyper-v windows services I was able to connect to the virtual machines as normal.
- Maitre EliasJan 06, 2021Copper Contributor
M Gibson correct and thanks for this fix, I changed the ListenerPort dword from 2179 to 21791 and was able to access the new VM. I have the most update-to-date win10 20H version.
Can somebody from MS indicate why this happens from time to time and if we should keep this different port?
- M GibsonJan 06, 2021Copper Contributor
Hi Maitre Elias I believe its to do with the reserved ports within Windows. Hyper-V seems to aggressively reserve a large range of ports.
At a command prompt, if you type netsh int ipv4 show excludedportrange protocol=tcp it will show the port exclusions. One of which is a range which contains port 2179.
You can run netsh int ipv4 set dynamic tcp start=51001 num=5000 which will reset the dynamic port range to start at 51001 which is a range applications typically have no port reservations to bind to.
Followed by running reg add HKLM\SYSTEM\CurrentControlSet\Services\hns\State /v EnableExcludedPortRange /d 0 /f which disables the HNS (Windows Container Host Networking Service) port exclusion behaviour.
Set your Hyper-V port back to the original value of 2179 and reboot your computer. You should now be able to launch Hyper-V, start a VM and connect to it.
Hope this helps you and others. Here are the links to the sources on the issue/fix:
https://hungyi.net/posts/wsl2-reserved-ports/
https://github.com/docker/for-win/issues/3171
- Maitre EliasJan 06, 2021Copper Contributor
M Gibson so many thanks, I will do but I have one concern, I use docker desktop on the win 10 box, so if I disable the HNS port wouldn't this affect how containers/docker work?