MySQL server has gone away

I had the same problem and I think I fixed it with the php.ini setting:
mysqlnd.net_read_timeout = 31536000

See: https://www.php.net/manual/en/mysqlnd.config.php
" Available since PHP 5.3.0. Before PHP 7.2.0 the default value was “31536000” and the changeability was PHP_INI_SYSTEM"