Too many database connections


Yesterday we started getting “too many database connections” error messages in the Apache error log. Fix
was to restart the MariaDB (5.5.52) server co-located. I’ve increased the max_connections to 200
in the database config. Any suggestions on why we might be seeing this “problem” - the number
of connected users wouldn’t have exceeded 35. I can’t find any reports of this “problem” occurring
in the past - anyone got any suggestions?


There’s a template for new support tickets, can you fill it out please?

Nextcloud version (eg, 10.0.2):
Operating system and version (eg, Ubuntu 16.04):
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 5.6):
Is this the first time you’ve seen this error?:

Can you reliably replicate it? (If so, please outline steps):

The output of your Nextcloud log in Admin > Logging:

The output of your Apache/nginx/system log in /var/log/____:

The output of your database log in /var/log/____:

Have you solved this problem?Thanks.

We increased the database connections to 800 to overcome the TOO MANY database connections.
The reason we’re getting so many connections is that we have any ongoing problem
with our backend NFS service which provisions the Nextcloud “data” directory. When it
is overloaded/running-slow Apache processes end up spawning but left stuck in flock or rpc_wait
and each one of the Apache processes generates database connections. In the default
configuration the Apache server spawns upto 256 processes IIRC.

simple daily cron job to restart apache is a fix too