The Elearning Community • FormaLMS Database Connection Issue
Page 1 of 1

FormaLMS Database Connection Issue

Posted: Mon Mar 03, 2025 1:06 pm
by gudiya
Hey,

We are a team of three working on FormaLMS and have been configuring it to meet our requirements. Recently, we encountered a database error stating "max_connections_per_hour exceeded" (currently set to 500).

Since we cannot modify this resource limit as it may affect other employees' work, we are looking for a solution within the FormaLMS codebase itself. Could you please guide us on how to resolve this issue? Additionally, let us know which code files we should check to address this problem.

Below is the attached screenshot with its stack trace. Please let me know if it helps.

P.S. We have already verified that database connections are being properly closed.

Re: FormaLMS Database Connection Issue

Posted: Mon Mar 03, 2025 1:15 pm
by alfa24
Hi,
I strongly encourage to host your forma instance in a dedicated vhost, not a shared one.
Anyway, you could try to alter the variable at runtime if your configuration allows such a thing.
To do that, based on your forma version, you could try to call the setting as follows:

sql_query("SET GLOBAL max_connections_per_hour = x");

where x is the wanted number.

Where to add the code?
Well, as I wrote above, it depends on your forma version, but generally it should be done at bootstrap.

Re: FormaLMS Database Connection Issue

Posted: Tue Mar 04, 2025 2:37 am
by gudiya
Thanks for the suggestion, alfa24, Just curious—why do you recommend a shared host over a virtual host? Also, we're currently using Forma LMS 4.0.1 (Community Edition).

Re: FormaLMS Database Connection Issue

Posted: Tue Mar 04, 2025 2:30 pm
by max
Hello, actually alfa24 said the opposite: he recommends a dedicated vhost and not a shared one.

Re: FormaLMS Database Connection Issue

Posted: Wed Mar 05, 2025 6:19 am
by gudiya
Sorry for missing that earlier, and thanks, Max, for pointing it out! Let me ask again—why would you recommend a virtual host over a shared one? Also, is there any way to fix the issue I mentioned while still using shared hosting?

Re: FormaLMS Database Connection Issue

Posted: Wed Mar 05, 2025 6:27 am
by alfa24
I provided a possible fix.
Regarding why a dedicated (virtual or physical, is not the point) is better than a shared, it's not a forma related question: 1vhost -> 1app, this means no shared configs (yes, you can achieve that with containers), that is exactly your prolbem