Various network and computer issues occur when TCP ephemeral ports are exhausted in Windows 8 or Windows Server 2012

Windows Server 2012 DatacenterWindows Server 2012 DatacenterWindows Server 2012 Standard

Symptoms


When a computer that is running Windows 8 or Windows Server 2012 runs out of or exhausts the number of TCP ephemeral ports, you may experience symptoms that resemble the following:
 
  • The computer crashes, freezes, or hangs.
  • The computer cannot access the Internet or a network file share.
  • The computer cannot log on to the domain.
Note You may experience other, similar symptoms that are not listed here.

Resolution


To resolve this problem, apply the hotfix that is mentioned in the "Hotfix information" section. After you apply this hotfix, Windows 8 and Windows Server 2012 can reuse ephemeral ports without having to wait for the TIMED_WAIT state to expire.

Note To resolve this problem for Windows 8.1 or Windows Server 2012 R2, see update 3149157.

Note Windows Server 2016 supports the auto-reuse port range feature by default.

How to use this new feature

This new feature introduces the following two socket option settings:
  • SO_REUSE_UNICASTPORT

    For a connection scenario to be implemented, the socket option must be set before binding a socket. This option instructs the system to postpone port allocation until connection time when the 4-tuple (quadruple) for the connection is known.
  • Auto-reuse port range

    You can set the auto-reuse port range using Windows PowerShell cmdlets. This separate port range is defined by the following two new TCP template parameters:
     
    • AutoReusePortRangeStartPort
    • AutoReusePortRangeNumberOfPorts
    You can set these parameters by using the PowerShell cmdlet Set-NetTCPSetting. The bounds for the smart port range are from port 1024 exclusive to port 65535 inclusive. The smart port range can partly cover the dynamic port range. In this case, ports that are in both ranges will be used only for smart port allocation.

    For an application to use these new socket parameters, the auto-reuse port range must be defined as in the following example:

    Set-NetTCPSetting –SettingName Custom -AutoReusePortRangeStartPort 40000  -AutoReusePortRangeNumberOfPorts 1000

Note Restart requirement: You have to restart the computer after you change the AutoReusePortRange settings for the setting to take effect.

After the reboot you can verify your defined settings using the PowerShell command:

Get-NetTCPSetting

Hotfix information

A supported hotfix is available from Microsoft Support. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing the problem described in this article. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, go to the following Microsoft website:

Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.

Prerequisites

There are no prerequisites for installing this hotfix.

Hotfix replacement information

This hotfix does not replace any previously released hotfix.

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

More Information


The current TCP stack in Windows 8 and Windows Server 2012 enables an application to open up to 58,000 outgoing ephemeral ports regardless of the number of unique remote endpoints.

Note Approximately 6,000 ephemeral ports are reserved for use by the system.

Ephemeral ports are a range of ports that are used for outgoing communications over the TCP/IP network protocol. By default, when an outgoing connection is finished, the port that is associated with the connection is put into a TIMED_WAIT state for two minutes. This enables any lingering packets on the network to be ignored.

Some applications and services such as Microsoft Exchange Server CAS servers can be very "chatty" and might actually use all ports in a two-minute time period.

Note Windows Server 2016 supports the auto-reuse port range feature by default.

References


Learn about the terminology that Microsoft uses to describe software updates.