What does the error mean?
MySQL is the system that stores your site's data in a database. Your website talks to it all the time. Sometimes the link between the two is cut. Then you see "MySQL server has gone away". It is like a phone call that drops in the middle.
Common causes
- Timeout: the connection sat idle too long, so MySQL closed it.
- Packet too big: a packet is one chunk of data sent to the database. If a chunk is larger than allowed, MySQL drops the link. This often happens when importing a large file.
- Server restart or crash: the database was off for a moment.
- Too little memory on the server.
- A very slow query that ran too long.
Quick fixes for any site
- Reload the page. If the error was brief, it will go away.
- Wait a few minutes and try again.
- Try again after big imports, with smaller files.
- Disable the last plugin you added, if you use WordPress. A faulty plugin can send huge or slow queries.
- If it keeps happening, open a support ticket. On shared hosting, only the server team can change the settings below.
Fix for VPS and dedicated servers
This part needs root access, which is full admin control of a server. Take a backup of the config file first.
- Log in to your server with SSH.
- Open the MySQL config file. Its path is often
/etc/my.cnfor/etc/mysql/my.cnf. - Under the
[mysqld]section, add or change these lines:
max_allowed_packet=128M
wait_timeout=600
The first line allows bigger data chunks. The second lets idle connections stay open for 600 seconds.
- Save the file.
- Restart MySQL:
This restarts the database service. On some systems the service is namedsystemctl restart mysqldmysqlinstead.
Tip: Check the MySQL error log for hints, such as a crash or an out-of-memory message.
Quick recap
- The error means the link to the database was cut.
- Common causes are timeouts, huge packets and restarts.
- Reload, then disable new plugins and use smaller imports.
- On a VPS, raise
max_allowed_packetandwait_timeout, then restart MySQL. - Ask support if it continues.