FormaLMS Database Connection Issue

Backend functionalities: user management, course management, reports, certificates, etc.
Post Reply
gudiya
Newbie
Posts: 3
Joined: Mon Mar 03, 2025 11:57 am

FormaLMS Database Connection Issue

Post 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.
alfa24
Senior Boarder
Posts: 2214
Joined: Fri Nov 24, 2017 8:45 am

Re: FormaLMS Database Connection Issue

Post 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.
Per supporto GRATUITO contattatemi in privato qui
gudiya
Newbie
Posts: 3
Joined: Mon Mar 03, 2025 11:57 am

Re: FormaLMS Database Connection Issue

Post 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).
User avatar
max
FormaLms Guru
Posts: 2775
Joined: Thu Mar 01, 2012 10:41 am
Version: forma.lms 2.4
Contact:

Re: FormaLMS Database Connection Issue

Post by max »

Hello, actually alfa24 said the opposite: he recommends a dedicated vhost and not a shared one.
---------------------
Massimiliano Ferrari
Elearnit - Elearning e Knowledge Management
https://www.elearnit.net
https://www.linkedin.com/in/massimilianoferrari
m.ferrari[at]elearnit.net
Skype: m_ferrari_it
gudiya
Newbie
Posts: 3
Joined: Mon Mar 03, 2025 11:57 am

Re: FormaLMS Database Connection Issue

Post 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?
alfa24
Senior Boarder
Posts: 2214
Joined: Fri Nov 24, 2017 8:45 am

Re: FormaLMS Database Connection Issue

Post 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
Per supporto GRATUITO contattatemi in privato qui
Post Reply