The default for both My
SQL and MariaDB for max_connections is 151.
As super user for your DB server verify:
mysql> show variables like 'max_connections';
to handle 300 at same time, suggest a little over ... like 351
in my.cnf file under [mysqld]
max_connections=351
then restart DB server.
There will probably be other needed tweaks upwards so suggest installing MySQL Tuner and run it with super user creds to see what it might have to recommend in settings.
Above not to say you shouldn't read/review the forums etc. related - do - you might find other things as well.
'SoS', Ken