"mysql server has gone away" error


Databases are key components of most modern websites so errors that affect yours tend khổng lồ be particularly worrisome. The “MySQL vps has gone away” error, for example, may make you believe that your database was lost. That means you might have to lớn resort to lớn your latest backup to lớn get your site up and running.

Bạn đang xem: "mysql server has gone away" error

See how xugame.biz stacks up against the competition. Select your provider WP Engine SiteGround GoDaddy Bluehost Flywheel HostGator Cloudways AWS Digital Ocean DreamHost Other Compare

Despite how intimidating it sounds, however, the”MySQL hệ thống has gone away” error is pretty easy to fix. In fact, with the right instructions, your website should be back up & running in a matter of minutes.

In this article, we’re going to show you what the “MySQL vps has gone away” error looks like and break down what can cause it in WordPress. Then we’ll teach you how khổng lồ fix it và prevent this error from showing up again in the future.

Let’s get khổng lồ work!

An Introduction to lớn the “MySQL hệ thống Has Gone Away” Error

First, let’s take a quick look at what the “MySQL vps has gone away” error looks like:

Browser showing the “MySQL server has gone away” error

The error itself is pretty straightforward & it almost always appears in the same way. Depending on which browser you use và your server’s configuration, however, the specific wording might change a bit.

As for the error itself, it has to vì chưng with your MySQL database, as you might imagine from the name. To be more specific, one of three things usually causes this error on most websites:

‘Packets’ have either been dropped or are too large. The server deems this to lớn be the case, it essentially closes the connection & throws up the error.

Fortunately, all of these issues can be easily addressed. Let’s talk about how you can start the troubleshooting process.

How to Fix the “MySQL vps Has Gone Away” Error in WordPress (3 Methods)

As we’ve seen, there are a few potential causes for this particular WordPress error.

For that reason, there are different possible solutions. In most cases, one of the fixes below should get rid of the error on your website. So if one doesn’t work, you can simply move on to the next.

1. Edit Your WordPress wp-db.php File

If your website’s PHP timeout setting is too low và your database is too large, fetching the data you need during that window can be a problem. As we mentioned before, this can trigger the “MySQL vps has gone away” error.

To prevent that from happening, you’ll need khổng lồ edit one of your WordPress vi xử lý core files, called wp-db.php. You can find this file within your WordPress root folder, by opening up the wp-includes directory:

The wp-db.php file

For accessing these files, we recommend that you use an FTP client such as FileZilla and connect via SFTP (understand the difference between FTP and SFTP). Once you’ve connected lớn your site, locate wp-db.php, và right-click on it to open the tệp tin using your default local text editor. Follow this quick guide lớn show all hidden files in Filezilla.

Then, tìm kiếm through the file for the following line:

$this->ready = true;Add the following line right below that code:

$this->query("set session wait_timeout=300");What this code does is phối your PHP timeout value to lớn 300 seconds, which should be a lot more than you need khổng lồ prevent any errors from showing up.

Xem thêm: Chuyển Đổi Số Doanh Nghiệp Là Gì ? Khác Biệt Giữa Số Hóa Và Chuyển Đổi Số

Now save the changes to your wp-db.php file và make sure your trang web is loading as it should.

Please chú ý that if you’re a xugame.biz user, you shouldn’t need to lớn alter your website’s PHP timeout settings. All of our plans have a base timeout value of 300 seconds out of the box & we can help you increase it depending on your needs.

2. Repair Your WordPress Database

Sometimes your WordPress database can become corrupted, which in turn can lead to errors when you’re trying khổng lồ establish a connection with it. This isn’t all that common but it can happen in the course of a normal website’s growth as you địa chỉ more tables lớn your database (as well as plugin và theme information).

To fix this issue, you can use a built-in WordPress function to lớn repair your database. First, however, you’ll have khổng lồ enable that feature. This involves navigating to lớn your WordPress root directory and opening the wp-config.php tệp tin in order to lớn edit it.

Once the file is open, scroll khổng lồ the bottom and add the following line khổng lồ it:

define("WP_ALLOW_REPAIR", true);That simple line of code tells WordPress khổng lồ enable the database repair function. Save the changes khổng lồ wp-config.php, và close the file. Khổng lồ run the function, just visit the following URL:


WordPress will then ask if you want to lớn simply repair your database or repair & optimize it. The first option is all you need to lớn fix the “MySQL hệ thống has gone away” error:

The repair database option in WordPress

The process shouldn’t take long, and when it’s done, the error in question should be gone. However, you still have some cleanup to do, as you’ll need to disable the database repair function on your website. If you don’t, anyone could trigger it by accessing the same URL.

Before you wrap up, therefore, return lớn your WordPress root directory & remove the line of code you added earlier. Then save your changes lớn the file & close it.

3. Restore Your website Using a Backup Through Your Hosting Provider

If all else fails, you can always use a full backup of your website to restore it khổng lồ a point when the database was working properly. Ideally, you’ll do this with a recent backup so that you thua as little data as possible.

The problem is that not all WordPress website hosts offer built-in backup functionality for their users. That means you’re often stuck using manual solutions such as plugins. These tools aren’t necessarily bad, but if you don’t have access khổng lồ your WordPress admin area, restoring a backup becomes a tall order.


xugame.biz provides automatic daily and system generated backups for all plans. Optional hourly backups are also available.

Here at xugame.biz, on the other hand, you get access to full backups of your trang web with every plan. Lớn restore your site (including its database) to an earlier point, you just have to lớn access your hosting dashboard & look for the Backups tab:

Restore your backup in Myxugame.biz

Click on the backup you want lớn restore và you’ll see more details about when it was created. For each backup, there’s a Restore button you can use khổng lồ return your website khổng lồ its state at that time.

Do remember, though: using this functionality will overwrite the current version of your website. So you’ll only want to use it as a last-resort measure when you’re sure you won’t thảm bại any critical information.


All xugame.biz plans features weekly automatic MySQL database optimization khổng lồ ensure better database performance. Kiểm tra out our plans for more info.

Experiencing the scary *MySQL server Has Gone Away* error in WordPress? Don"t sweat it, here are 3 ways khổng lồ fix it immediately!