0

I got this problem where I have developed a Laravel application which uses or connects to a external database.

I have copied all Laravel files in a CentOS server that needs to connect to a MySQL database that is located in another (Ubuntu) server.

Locally, I didn't have any trouble with Laravel Homestead.

But now the Laravel app throws the following error:

SQLSTATE[HY000] [2006] MySQL server has gone away

And if I try to connect to the external database from the CentOS terminal,

$ mysql -h xxx.xxx.xxx.xxx -P 3306 -u user4laravel -p

I get this other error:

ERROR 2013 (HY000): Lost connection to MySQL server at 'handshake: reading inital communication packet', system error: 11

Notes: I connect to that server via SSH Tunnel with SSH-KEY and passphrase. Do I have to create a tunnel connection?

How do I make it persistent? Is this practical? Or ... Does anybody know how to solve this or a workaround?

Pathros
  • 10,042
  • 20
  • 90
  • 156
  • I'd guess you have a firewall that isn't allowing connections on port 3306 to get through. Perhaps a software firewall running on the Ubuntu server, or perhaps other network routing issues. – Bill Karwin Sep 12 '18 at 00:24
  • [gone away possible causes/solutions](https://dev.mysql.com/doc/refman/5.7/en/gone-away.html) – danblack Sep 12 '18 at 02:15
  • Oh, sorry. It was because of `hosts.allow` file. As explained [here](https://stackoverflow.com/a/12062266/1883256) – Pathros Sep 12 '18 at 21:20

0 Answers0