This error can happen when the client is attempting an initial connection to the server. If your connect_timeout value is set to only a few seconds, you may be able to resolve the problem by increasing it.
Before increasing the value of connect_timeout, first determine its current value. This can be done by executing the following SQL statement:
SHOW VARIABLES LIKE 'connect_timeout'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | connect_timeout | 2 | +-----------------+-------+
Normally, setting this variable to ten seconds would be sufficient. You might want to set it to more than ten seconds if you have a very long distance or slow connection. You can determine whether you are experiencing this more uncommon cause by using the following SQL statement:
SHOW STATUS like 'aborted_connections';
This statement usually will return an empty set. However, if you have been experiencing aborted connections, the value will increase by one for each initial connection attempt that the server aborts.
To change this value of connect_timeout, you can use the SET statement. You will need SUPER privileges.
SET GLOBAL connect_timeout = 20;