Re: Windows Server 2016 Connection Issues
Posted by: strad solutions
Date: April 10, 2021 03:55AM

One of the main reasons why you get ‘Cant connect to MySQL server’ error is that Windows does not allow enough short-lived (ephemeral) ports to serve those connections.

Windows permits ephemeral (short-lived) TCP ports to the user. After any port is closed, it remains in a TIME_WAIT status for 120 seconds. The port is not available again until this time expires.

With a small stack of available TCP ports (5000) and a high number of TCP ports being open and closed over a short period of time along with the TIME_WAIT status you have a good chance for running out of ports. There are two ways to address this problem:

• Reduce the number of TCP ports consumed quickly by investigating connection pooling or persistent connections where possible
• Tune some settings in the Windows registry (see below)

The following procedure involves modifying the Windows registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore it if a problem occurs. For information about how to back up, restore, and edit the registry, view the following article in the Microsoft Knowledge Base:

1. Start Registry Editor (Regedt32.exe).
2. Locate the following key in the registry:
3. On the Edit menu, click Add Value, and then add the following registry value:

Value Name: MaxUserPort
Data Type: REG_DWORD
Value: 65534

This sets the number of ephemeral ports available to any user. The valid range is between 5000 and 65534 (decimal). The default value is 0x1388 (5000 decimal).

On the Edit menu, click Add Value, and then add the following registry value:
Value Name: TcpTimedWaitDelay

Data Type: REG_DWORD
Value: 30

This sets the number of seconds to hold a TCP port connection in TIME_WAIT state before closing. The valid range is between 30 and 300 decimal, although you may wish to check with Microsoft for the latest permitted values. The default value is 0x78 (120 decimal).

Quit Registry Editor.
Then reboot the machine

Options: ReplyQuote

Written By
Re: Windows Server 2016 Connection Issues
April 10, 2021 03:55AM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.