09-24-2020 12:32 PM
09-24-2020 12:32 PM
I seem to be running short of ephemeral ports for tcp connections on IPv4. This has lead me to try get a solid understand of just how many ephemeral (eph) ports I have available for IPv4 tcp connections.
I start with the output from netsh int ipv4 show dynamicport tcp which outputs I have 16384 ports in my tcp Dynamic Port Range. I know I can increase this number but this is just a calculation exercise.
Now assume my server has multiple NICs and of course multiple IPs as well as loopback - 127.0.01.
I kind of doubt that I have only 16384 eph ports available across the entire host regardless of the number of local IPs.
Perhaps I have 16384 eph ports available per local IP. That makes more sense. But I know in terms of making a unique tcp connection I need a eph port for each outgoing connection to a foreign host's individual listener.
My port exhaustion seems to be on loopback so let me put my question like this:
using this format : LocalHost:ephPort --> RemoteHost:Listener
for example, do I have
a) 127.0.0.1:EphPort[16384 possibilities] --> 127.0.0.1:443 and
127.0.0.1:EphPort[16384 possibilities] --> 127.0.0.1:444 and so on
b) 127.0.0.1:EphPort[16384 possibilities] -->127.0.0.1:[regardless of listener]
c) Host: EphPort[16384 possibilities] --> RemoteHost
Another thing that has lead to my question above is the word global in event #4231 I am getting.
"A request to allocate an ephemeral port number from the global TCP port space has failed due to all such ports being in use."
Perhaps I should have just asked for the definition of the global TCP port space.
09-24-2020 05:14 PM - edited 09-24-2020 05:25 PM
You asked about limits of port space so I was answering that. (65,535)
Generally if a process uses some dynamically assigned range of ports and didn't complete (and close) successfully and is repeatedly being triggered then it may be expected behavior to eventually run out of ports.
should show the result. The short term fix is to reboot. A long term solution is fixing the problem process or connection issues.
09-24-2020 05:34 PM
These are big servers with thousands of users. Netstat outputs about 180K lines, most of the time netstat doesn't complete, same for the PS Get-NetTCPConnection. This doesn't appear to be a process leaving connections open; I think its just a busy box running up against an ephemeral limit which is why I would like to know what the global TCP port space actually is. From that perhaps we could figure if there is anyway to add more ephemeral ports, that is, allow more connections.
09-24-2020 05:39 PM
May depend on the process or service. Some windows services port usage are listed here.
The space is up to 65,535 but of course you'll need to know what's being used by windows and or other processes so as not to cause conflicts.