Theme editor

Guide Fixing “2006 MySQL Server Has Gone Away” Error & Increasing max_allowed_packet (2025 Guide)

  • Thread starter Thread starter CL4Y
  • Start date Start date
  • Views 132

CL4Y

Keyboard Ninja
Administrator
Thread owner

Fixing “2006 MySQL Server Has Gone Away” Error & Increasing max_allowed_packet

When working with MySQL, the “2006 MySQL server has gone away” error is one of the most common issues.
It typically occurs during large data queries or long-running operations.
The most frequent cause of this error is an insufficient max_allowed_packet value.



🔍 What Is max_allowed_packet?

The max_allowed_packet variable defines the maximum data packet size that MySQL can handle in a single session.
If the data being sent exceeds this limit, MySQL terminates the connection and triggers this error.



🛠️ Solution: Increase the max_allowed_packet Value

The fix is straightforward. Follow these steps to increase the packet size limit.



Edit the MySQL Configuration File (my.cnf or my.ini)

On most servers, the configuration file is located in one of the following paths:
  • nano /etc/my.cnf
  • nano /etc/mysql/my.cnf
  • C:\ProgramData\MySQL\MySQL Server X.X\my.ini (Windows)

Under the [mysqld] section, add or update the following lines:
Bash:
[mysqld]
wait_timeout = 31536000
max_allowed_packet=1024M
Note: You can use 64M, 128M, or 256M depending on your data size requirements.

Restart the MySQL Service

Bash:
service mysqld restart
If you’re using Plesk or cPanel, you can restart the MySQL service directly from your control panel interface.

jetto-mysql-2006-error-fix.webp
 
Back
Top