Info
Content

Too Many Connections


When your Moodle database is overloaded you might see errors like this (MySQL/MariaDB) in your PHP error log and a similar message in your MySQL/MariaDB log.

mysqli::mysqli(): (HY000/1040): Too many connections in /lib/dml/mysqli_native_moodle_database.php on line 376
mysqli::mysqli(): (08004/1040): Too many connections in /lib/dml/mysqli_native_moodle_database.php on line 376

This indicates you have reached your max_connections settings.

Check in MySQL with an appropriately privileged account e.g. root.

mysql> SELECT @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
|               200 |
+-------------------+

Also check how many are in use using:

mysql> SHOW STATUS LIKE 'max_used_connections';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 16    |
+----------------------+-------+

This definied in your my.cnf configuration e.g. under /etc/my.cnf though it may not be set and you may need to add it as a setting.

[mysqld]
max_connections                = 200
NOTE: you can set this in the mysql client while it is online if you don't want to do a DB restart e.g. SET GLOBAL max_connections = 200; but but aware this will be cleared next restart so make sure you also update my.cnf.
No Comments
Back to top