This topic describes the symptoms, cause, and solution for external network access failures on a Windows instance caused by an excessive number of TCP connections in the TIME_WAIT state.
Symptoms
You can successfully ping an external network from your Windows instance, but you cannot browse external websites, web pages load slowly, or applications on the instance have network connectivity issues. When you run the netstat -an |find "TIME_WAIT" /c command in Command Prompt, the output shows a large number of TCP connections in the TIME_WAIT state. The following figure shows an example.
Cause
In Windows Server 2008 and later, the default dynamic port range includes 16,384 ports, from 49152 to 65535. The default TIME_WAIT delay for a TCP connection is 4 minutes. If a system handles a high volume of active connections, the ports can remain in the TIME_WAIT state for an extended period after the connections are closed. This can lead to port exhaustion, which prevents applications from establishing new connections.
Solution
Steps may differ for other Windows versions.
Connect to the Windows instance using VNC.
For more information, see Connect to an instance using VNC.
Open Command Prompt.
Click the
icon in the lower-left corner of the desktop, and then click the
icon.In the search box, enter
cmd.
Click Command Prompt.
The Command Prompt window opens.

Run the following command to view the current dynamic port configuration.
netsh int ipv4 show dynamicport tcpThe output is similar to the following, which indicates that the number of dynamic ports is 16,384 (from 49152 to 65535).

Run the following command to increase the number of dynamic ports.
netsh int ipv4 set dynamicport tcp start=1025 num=60000NoteThe
startandnumparameters specify the starting port and the total number of ports, respectively. Adjust these values based on your requirements.The output is similar to the following, which indicates that the number of dynamic ports is increased to 60,000, ranging from 1025 to 61024.

Try to access the external network or connect to your application again.
If the access is successful, the issue is resolved.
If access fails, continue to the next step to shorten the TIME_WAIT delay by modifying the registry.
If increasing the number of dynamic ports does not resolve the issue, you can reduce the TIME_WAIT delay by modifying the registry. The minimum supported value is 30 seconds. Perform the following steps:
ImportantModifying the registry incorrectly can cause serious system problems or data loss. Before you proceed, you must create snapshots of the system disk and data disks. After you modify the registry, you must restart the Windows instance for the changes to take effect.
To create a snapshot, see Create a disk snapshot.
To restart the Windows instance, see Restart an instance.
Open Registry Editor.
Click the
icon in the lower-left corner of the desktop, and then click the
icon.In the search box, enter
regedit.
Click regedit.
The Registry Editor window opens.

In Registry Editor, navigate to the
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameterskey and set the Value data of theTcpTimedWaitDelayentry to a decimal value of30.If the
TcpTimedWaitDelayentry does not exist, create the corresponding registry entry, and then modify its value data. For example, ifTcpTimedWaitDelaydoes not exist, perform the following steps:Under the
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameterskey, right-click an empty area in the right pane and select New > DWORD (32-bit) Value.
Enter
TcpTimedWaitDelayand pressEnter.Right-click the
TcpTimedWaitDelayentry and select Modify.
In the dialog box that appears, select Decimal and set Value data to
30.
Click OK.