Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EdwinvanDessel's avatar

Lost communication to MySQL server

Hi,

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:

  1. Firewall-issues - but in that case I should not be able to connect at all and initially I can connect
  2. 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.

Anybody an idea?

0 likes
6 replies
willvincent's avatar

What are the timeout values in your config file? /etc/mysql/my.cnf

Specifically the wait_timeout and interactive_timeout.

You could try increasing those (sudo nano /etc/mysql/my.cnf) and then restarting the service (sudo service mysql restart)

Note: Yes, even when running maria instead of mysql, the service name is still mysql.

jimmck's avatar

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 :)

EdwinvanDessel's avatar

Hi,

Thanks for the quick answers. Experiences so far:

  • Increased the wait_timeout from the default 600 to 1200 - does not help
  • There is no parameter interactive_timeout in the my.cnf file
  • It just happens after a few minutes whether I leave the server alone or busy querying the database
  • No CRON jobs running on my development machine
zachleigh's avatar

Did you check the logs? Both for laravel and mysql/mariadb. Might give you a better idea of whats happening.

EdwinvanDessel's avatar

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!

Thanks a lot for your help

1 like

Please or to participate in this conversation.