MySQL Server Has Gone Away error


  • Applies to: Grid
    • Difficulty: Easy
    • Time Needed: 10
    • Tools Required: Account Center access
  • Applies to: VPS Hosting
    • Difficulty: Easy
    • Time Needed: 10
    • Tools Required: Account Center access
  • Applies to: Shared Hosting
    • Difficulty: Easy
    • Time Needed: 10
    • Tools Required: Account Center access
  • Applies to: Managed WordPress
    • Difficulty: Easy
    • Time Needed: 10
    • Tools Required: Account Center access

Overview

The following article will provide information and troubleshooting steps for your website for the following error:

MySQL Server Has Gone Away

When you first encounter this error, you might be confused, "What the is MySQL anyways?  And why has it gone away?" Despite the language, usually it's not that something has actually "gone away," but there something has happened between your website's database and MySQL (which is your server's database management system). Some common reasons for this error are:

  1. Your php timeout is too low.
  2. A database table has become corrupted or broken.
  3. Database packets are being dropped or are too large.

Luckily fixing this error can be done fairly easy, which we will cover in the next section.

Instructions

Increase php timeout

NOTE:
In order to update wait_timeout you will need a GridContainer to update edit your server's my.cnf file.

  1. Log into your Account Center.
  2. Navigate to your GridContainer.
  3. Scroll down to the MySQL Config section. Click EDIT CONFIG to open the editor.
    g-6.png
  4. Edit your my.cnf file and update wait_timeout to a higher value, such as 300. When you are done click Save Config.
    g-1.png
  5. You can check your website to see if your site is working again. If not, you can continue with the steps below.
  1. Access your server using SFTP or SSH.
  2. Navigate to your my.cnf file. This will be located under /etc/my.cnf
  3. Update or add the following line of code to my.cnf:
    wait_timeout=300
  4. Save your changes.
  5. Reboot your server or just the MySQL service.
  6. Your php timeout should now be increased. You can check your website to see if your site is working again. If not, you can continue with the steps below.

Repair Database tables

  1. Log into phpMyAdminphpMyAdminphpMyAdminphpMyAdminphpMyAdmin.
  2. Select the correct desired database.
    db-0.png
  3. Click on the Structure tab. Then select the appropriate box to select all your tables.
    db-1.png
  4. From the drop-down, select Repair Table.
    db-2.png
  5. Your tables should now be repaired. You can check your website to see if your site is working again. If not, you can continue further with the steps below.

Disabling plugins & themes

Plugins and themes are one of the most common reasons for a site to go down. We can try to narrow down potential culprits by disabling all of them, check if your site is working, then slowly re-enable them one at a time. If you re-enable a plugin or theme and your site suddenly goes back down, then you'll know which one is causing the issue. From there you can investigate further with your website developer or the developer of the plugin/theme. If you'd like a refresher on how to disable these, feel free to view the articles below:

Restore from a backup

If all the above solutions have not fixed your site, then you may want to restore from a backup. For a list of of available backup options on your server, feel free to check out the article below: