I’m getting a ‘MySQL server has gone away’ error in my application

There are two main reasons for this error message to show:

1) The MySQL query you are trying to execute takes too long and the MySQL server times out.

The solution for this issue is to optimize your database for the queries which fail.

2) You have a crashed table in your database.

The solution in this case is to repair and optimize your database.

If a particular table crashes often and repairing/optimizing it does not help,  this most probably means that the table's structure has an issue with our MySQL server setup. In such cases the easiest way to fix a crashed MyISAM table for good is to change its database engine from MyISAM to InnoDB.

More information on how to do this can be found in this article.

You find this article useful? Click here to learn more about SiteGround web hosting experts and what else we can do for you!

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

My Facebook application is displaying ‘Method Not Allowed’

If you are encountering this problem with your Facebook application hosted on your SiteGround...

What to do if your website has been marked by Google as harmful

If you see the following warning when you visit your site: This site may harm your computer....

HTTP error codes explained

There are multiple HTTP codes that you may come across. Below you can find a summary of the most...

Cannot modify header information – headers already sent by …

If you receive a warning on your pages similar to the one below: "Warning: Cannot modify header...

Error: Sessions directory is not writable

By default, such an error is received when you use a custom php.ini file and the directive...