Sunday, October 4, 2020

Configuring Windows Dynamic Port Allocation?

Some Windows applications can reserve TCP or UDP ports which may cause some other applications fail to run. These threads provide solutions to this problem,

The solution are generally three.

  1. Removing/disabling the offending application or Windows feature. For instance, the threads point out Hyper-V is often the culprit because it reserves ports dynamically and unpredictably. We can disable it if we aren't using it,
    
    REM disable Hyper-V
    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
      
    In PowerShell, do this to remove all Hyper-V adapters,
    
    Get-HNSNetwork | Remove-HNSNetwork
      
  2. Reset dynamic port range from which the offending application reserves ports. For instance, for Hyper-V, for instance, we can do this,
    
    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
    
    netsh int ipv4 add excludedportrange protocol=tcp startport=50051 numberofports=1
    
    dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
        
  3. Disable dynamic port allocation, i.e.,
    
    reg add HKLM\SYSTEM\CurrentControlSet\Services\hns\State /v EnableExcludedPortRange /d 0 /f
        

No comments:

Post a Comment