When I attempt to query an RDS DB instance running the MySQL Server engine, I receive the error message "MySQL server has gone away" or "Lost connection to server during query."

The most common reason for this error is that the server timed out and closed the connection. In this case, you will typically receive one of the following error codes:

Error code



The client couldn't send a question to the server.


The client didn't get an error when writing to the server, but it didn't get a full answer (or any answer) to the question.

Review the following potential causes and resolutions for this error:

  • This error can occur when a connection has been idle for a long period of time and the connection was not terminated correctly from the client. In this case, verify that application timeouts are shorter than MySQL timeouts and ensure that your applications close idle connections.
  • For a less elegant quick fix, you can try increasing the timeouts for MySQL by increasing the 'wait_timeout' and 'interactive_timeout' parameters by using a custom parameter group.
  • If the query that is generating the error is retrieving a large data set, you might need to increase the 'max_allowed_packet' size parameter by using a custom parameter group.
  • If this error is only occurs when returning large data sets, it is possible that the client is using a large MTU value of 9001; in this case, you may want to reduce the client TCP/IP MTU value. For information on changing your client MTU value, see Configuring the MTU of an Instance. For more information about MTU and Jumbo frames, see Network Maximum Transmission Unit (MTU) for Your EC2 Instance.
  • Ensure that all 'init_connect' parameters are being processed correctly. If any of these parameters are set to a value that prevents the parameter from being processed, associated client connections may fail. Ensure that the user has EXECUTE permission on any procedures referenced as an 'init_connect' parameter. For example, when implementing the time zone procedure workaround described in the blog post Changing MySQL timezone on Amazon RDS, if the user does not have EXECUTE permission on the described procedure, connections from that user fail when the associated 'init_connect' parameter is not processed.
  • Confirm that other connections are still working when this issue occurs. If all connections are dropping at the same time, the issue is probably not connection specific. In this case, verify the MySQL DB instance is not crashing or failing over by viewing Amazon RDS events and reviewing your MySQL error logs.
  • Review the MySQL documentation B.5.2.9 MySQL server has gone away for other potential causes and resolutions to this issue.

RDS, MySQL, lost connection, timeout, CR_SERVER_GONE_ERROR, CR_SERVER_LOST, DB instance, parameter group

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center.

Published: 2015-11-23