Help Center> Relational Database Service> Troubleshooting> RDS for MySQL> Connection Issues> RDS for MySQL Client Automatically Disconnected from a DB Instance
Updated on 2023-03-06 GMT+08:00

RDS for MySQL Client Automatically Disconnected from a DB Instance

Description

The RDS for MySQL client was automatically disconnected from the DB instance. The following error is displayed: ERROR 2013: Lost connection to MySQL server during query.

Solution

ERROR 2013 is usually caused by inappropriate settings.

  • wait_timeout: indicates the number of seconds the server waits for activity on a non-interactive connection before closing it.
  • interactive_timeout: indicates the number of seconds the server waits for activity on an interactive connection before closing it.
  1. Check whether the DB instance is available.

    If the DB instance is available, check for other possible causes.

  2. View error logs.
  3. Use the RDS for MySQL command-line client to connect to the database. Run status to check whether the DB instance has been rebooted a lot.

    Uptime indicates the running time of the DB instance. The command output shows that the database has not been restarted frequently. Therefore, the client disconnection is not caused by a database restart.

  4. Check parameters. If the values of wait_timeout and interactive_timeout are too small, the RDS for MySQL client automatically stops connections as they time out.
  5. You can change the values of wait_timeout and interactive_timeout based on service requirements, and there is no need to reboot the DB instance.
  6. After about 10 minutes, run the show databases command to check whether the connection is normal.

    If information similar to the preceding figure is returned, the connection is normal.