Magento MySQL Has Gone Away Error
This is mostly due to any of the below two reasons
- Server timed out and closed the connection.
fix: try increasing thewait_timeout
variable in your mysqld’smy.cnf/my.ini
configuration file. - Server dropped an incorrect or too large packet.
fix : increase the maximal packet size limit by increasing the value ofmax_allowed_packet
inmy.cnf/my.ini
file.
Please check in files if you are trying to get something that is taking too long or inapplicable.
Issue resolved! Thanks to all for the help. This was a hardware firewall issue with the web host, even after they were disabled by us.
As confirmed by 1&1's server team, the hardware firewalls were correctly configured, but they were incorrectly intercepting valid traffic between the file server and the db server about 25% of the time.
We have configured iptables instead and shutdown the hardware firewalls entirely. 100% availability now.
I experienced the same issue for Magento 2.1 and my mysql error log showed the following error multiple times during the "MySQL has gone away" process:
...[Warning] File Descriptor 1228 exceeded FD_SETSIZE=1024
To potentially resolve this issue, firstly check the open files
value with $ ulimit -n
, which in my case was 256
.
Secondly, add table_open_cache = {that ulimit -n value}
under the [mysqld]
section in your my.cnf
.
Now restart MySQL and hopefully you're back into the action.
Note: I'm running Magento 2.1 locally on OS X El Capitan with PHP 7.1 and MySQL 5.7.15 build with Homebrew. But I bet this solution would work on older or different setups too.