Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 31.6Mb
PDF (A4) - 31.6Mb
PDF (RPM) - 30.5Mb
HTML Download (TGZ) - 7.6Mb
HTML Download (Zip) - 7.6Mb
HTML Download (RPM) - 6.5Mb
Man Pages (TGZ) - 170.9Kb
Man Pages (Zip) - 280.0Kb
Info (Gzip) - 3.0Mb
Info (Zip) - 3.0Mb
Excerpts from this Manual

B.5.2.3 Lost connection to MySQL server

There are three likely causes for this error message.

Usually it indicates network connectivity trouble and you should check the condition of your network if this error occurs frequently. If the error message includes during query, this is probably the case you are experiencing.

Sometimes the during query form happens when millions of rows are being sent as part of one or more queries. If you know that this is happening, you should try increasing net_read_timeout from its default of 30 seconds to 60 seconds or longer, sufficient for the data transfer to complete.

More rarely, it can happen when the client is attempting the initial connection to the server. In this case, if your connect_timeout value is set to only a few seconds, you may be able to resolve the problem by increasing it to ten seconds, perhaps more if you have a very long distance or slow connection. You can determine whether you are experiencing this more uncommon cause by using SHOW GLOBAL STATUS LIKE 'Aborted_connects'. It will increase by one for each initial connection attempt that the server aborts. You may see reading authorization packet as part of the error message; if so, that also suggests that this is the solution that you need.

If the cause is none of those just described, you may be experiencing a problem with BLOB values that are larger than max_allowed_packet, which can cause this error with some clients. Sometime you may see an ER_NET_PACKET_TOO_LARGE error, and that confirms that you need to increase max_allowed_packet.

User Comments
  Posted by Duncan Ferguson on November 18, 2010
This error can be caused by having tcp wrappers set up on your database server. If you have entries in /etc/hosts.deny and /etc/hosts.allow adding the following to hosts.allow may solve the problem:



mysql -h localhost -u user -p

may work, whereas

mysql -h -u user -p

may not - this is because 'localhost' is swapped to using a file socket, but forces use of the TCP socket.
  Posted by Kristian Ask on December 7, 2010
If you're on a remote connection and loose connections frequently check if skip-name-resolve is in my.cnf.

In my case it was the name lookup causing the infamous lost-connection issue.

If you don't want to use ip-addresses and don't want to turn it off check your dns... make sure your nameserver(s) are in /etc/resolv.conf
  Posted by Peter Hug on May 15, 2012
Stephen Adkins made a suggestion here which resolved the issue for me:,6916,184947
  Posted by Manfred Bruckhaus on September 15, 2015
In my case it was a windows firewall, preventing the acces from application to database on the same machine.
Sign Up Login You must be logged in to post a comment.