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

11/29/2018 10:25 PM

Last published date

4/15/2020 11:22 PM

Overview

If there are a large number of open ports on the Orion server, this is an indication of Port Exhaustion and can lead to performance problems, including polling failures and Ping failing to work on the Orion Server. This article shows how to check for this.

Product section

Server Application Monitor

Resolution

In the command prompt, run the command:
#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" /c
Powershell 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).count
The 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