Forum Discussion
M Gibson
Nov 17, 2018Copper Contributor
Windows 10 1803 to 1809 Hyper-V - Cannot connect to the virtual machine
Windows 10 1803 to 1809 Hyper-V - Cannot connect to the virtual machine Hi all, After upgrading from Windows 10 1803 to 1809 I am no longer able to connect to any running VM's. I am able to start ...
Maitre Elias
Jan 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 Gibson
Jan 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?
- M GibsonJan 07, 2021Copper Contributor
Hi Maitre Elias. I also run docker desktop with both the docker and kubernetes engine service on Win 10 20H2 and so far, I haven't run into any issues.
Hope this helps
Mark.