Fix Laravel Valet – MySQL Has Gone Away

There seems to be a bug when using MySQL in combination with the latest macOS release. After some time, MySQL stops working. I discovered the problem mostly when working with WordPress and Laravel Valet.

You may discover the problem when you find something similar to “MySQL server has gone away” in MySQL logs or as output of a command. An example entry from the MySQL log:

SQLSTATE[HY000] [2006] MySQL server has gone away
/system/ee/legacy/database/drivers/mysqli/mysqli_connection.php:82

To solve this issue, add these two lines to your MySQL configuration file named my.cnf:

interactive_timeout = 300
wait_timeout = 300

You can locate the my.cnf by using one of these two commands from the terminal:

locate my.cnf

or

mdfind -name my.cnf

After restarting MySQL, the problem should be gone.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top