Plex Library Scans Initiate Hundreds of TCP_WAIT Sessions using up all available ports?

Server Version#: 1.14.1.5488

My setup is as follows: Windows 10 Pro running Plex media server. My media files are stored on a Synology NAS and the volumes are mapped on the windows PC running plex. I am using a AQUANTIA 10 Gigabit NIC running to a Netgear 10gbe switch (SX10). My Synology does not have 10gbe (yet), so it has 2 ethernet ports in link aggregation to the same switch.
I recently moved my server to this setup and ever since then my mapped drives are becoming inaccessible until the reboot the server or disable and enable the nic card. In the windows event viewer, I see this error corresponding to when this is happening:

Event 4227
TCP/IP failed to establish an outgoing connection because the selected local endpoint was recently used to connect to the same remote endpoint. This error typically occurs when outgoing connections are opened and closed at a high rate, causing all available local ports to be used and forcing TCP/IP to reuse a local port for an outgoing connection. To minimize the risk of data corruption, the TCP/IP standard requires a minimum time period to elapse between successive connections from a given local endpoint to a given remote endpoint.

From what I found online, this points to software using up all the ephemeral ports on the system. I have noticed by running TCPView that Plex is using a ton of ports when doing library scans and leaving them in TCP_WAIT status. Normally, there is under 50 ports in TCP_WAIT. You can see in the screenshot that there are over 400 now and the majority are for the localhost port 32400 (which is my Plex Port). I have seen this go up to over 900 in one scan.

Is this normal? I have never had issues until moving my server over but no matter what, I keep having this happen every 12-24 hours (I am assuming after many scans all the ports are used up and that maybe windows is not correctly recycling them). I tried changing back to regular 1 gig ethernet, removing the switch and plugging directly into the router, and the same issue occurs. I have been running an analysis on my plex library as well to generate all of the thumbnails, so maybe that in addition to library scanning causes the ports issue and thus causing my mapped drives to disconnect?

I am out of ideas and not sure what could be causing this. I really only have plex running on this system and have confirmed that windows defender and firewall are excluding anything plex related. Any assistance or ideas are greatly appreciated.

Forgot to mention, I also tried a fresh install of windows 10 along with updating my ethernet driver and still get the same issues

What does “netsh int ipv4 show dynamicport tcp” return ?

(command line or powershell)

Philippe

Protocol tcp Dynamic Port Range

Start Port : 49152
Number of Ports : 16384

The default. You can add more ephemeral ports.

With an elevated command prompt:

PS C:\WINDOWS\system32> netsh int ipv4 set dynamicport tcp start=32768 number=32768
Ok.

PS C:\WINDOWS\system32> netsh int ipv4 show dynamicport tcp

Protocol tcp Dynamic Port Range

Start Port : 32768
Number of Ports : 32768

That doubles the amount of available ports. See if that works for you.

Philippe

You mentioned this was on a fresh Windows 10 install, Windows updates run as well? I ask because I recall a known issue earlier this year with NT10 systems not releasing application ports. MS released a fix pretty quickly, but sadly I can’t find my notes on the subject so not sure what KB number it was.

I mentioned these values are the default. This is off a WIN10 up to date machine. I would just add more ephemeral ports to test and see if that solves your problem. You can also change the tcp time_wait, but I would wait before going there (just my cautious side :slight_smile: )

Yes, the windows machine is fully up to date with Windows Updates. I have increased the amount of ports as suggested and will see if this reoccurs over the next few days.

I also did see something while investigating this issue regarding windows not releasing ports, but then saw that a fix was released for that so I assumed that I received that fix over windows update as well. I will look into that more as well if the issue reoccurs.

Thanks!

:+1:

Philippe

This seemed to have worked. No more mapped drive disconnects or event log errors. Very odd that this seemed to have just started happening after migrating my existing Plex server, but as long as it’s working now. Thanks all!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.