Applications Systems
Check the number of ephemeral ports in use
This article describes how to check the number of TCP ports (that is, ephemeral ports) that are currently in use. This is useful for troubleshooting all ports in use. Port Exhaustion
First published date
Last published date
Overview
Product section
Resolution
#Lists all active TCP connections Netstat -nao #Lists all connections that contain Time_Wait netstat -nao | find /i "time_wait" #Gives a count of all lines/ports with a Time_Wait netstat -nao | find /i "time_wait" /cPowershell equivalent:
#Lists all active TCP connections Get-NetTCPConnection #Lists all Time_Wait bottom gives count of Time_Wait connections. Get-NetTCPConnection -state timewait (Get-NetTCPConnection -state timewait).count #Lists all Close_Wait bottom gives count of Close_Wait connections. Get-NetTCPConnection -state closewait (Get-NetTCPConnection -state closewait).countThe output of the above commands will show you the port utilization. If you are getting the count of more than 200-300 ports that are in a TimeWait or a CloseWait state you might encounter port exhaustion due to port limitations and get an error like "Insufficient Winsock resource available" but in order to get rid of it you need to create MaxUserPort key in the registry to provide enough ports to use. Tweaking Windows Server performance to prevent port exhaustion when using Orion modules (solarwinds.com)
If you feel that you are running into port exhaustion please see this article for details on how to address this: Ephemeral Port Exhaustion On Solarwinds Orion Servers