I am using the latest Laravel Homestead Vagrant box in a complete standard way on VirtualBOx with MariaDB as database. Everything boots up nicely and works fine at first. But after a few minutes the connection to the database is refused, whether I try to connect from Navicat or directly from PHPStorm with the message:
'Lost connection to MySQL server at reading initial communication packet, system error: 0. Internal error/check (Not system error)'.
Searched on Internet and found two possible causes:
Firewall-issues - but in that case I should not be able to connect at all and initially I can connect
Do 'sudo reboot' of the system - this works indeed but again only for a few minutes (and rebooting every few minutes does not really improve my productivity).
I increased the available memory for the Homestead box to 8GB but that does not help either.
By the way, after receiving this error message I can still SSH without problem into my Homestead box, so no problems there.
Are you doing queries prior to the timeout? If you look at the db process what are its stats? If you do nothing after restart for a period of time does this happen? Do you have any CRON jobs which ping the database? Databases tend to stay up and if Sybase does not like your query it will terminate it :)
Followed the instructions in the article jimmck posted and it seems this has done the trick. So it seems the problem was caused by security stuff in AppArmor of Ubuntu itself. Still do not understand why this happens in a complete default install of Laravel Homestead but it has done the trick and I can get back to work!