Support ⇒ Troubleshootings ⇒ connection to Database server failed (too many connections) ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexTroubleshootings

connection to Database server failed (too many connections) Reply to topic


Hi, if you go to my site catholicwritersguild.com, you'll see the following message:

The connection to the database server failed, sorry for the inconvenience

We should be back shortly

---

Now, I spoke to the service provider, and it says I have too many SQL connections to the database. I must admit, I am still a bit of a newb at this and I have no idea what that means. I've tried reinstalling dragonfly to connect it to the database wondering if perhaps the code was hacked or something and that installing the upgrade would allow the site to talk to the database again. No dice. The username and password for the database all line up. So...what is happening? Can someone give me some guidance?

Thanks for any help you can give me. Bless you guys.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/PHP Version 5.2.17 MySQL Version 5.5.32-log (client: 5.5.32)/Dragonfly 9.3.4.0


In includes/config.php change
define('CPG_DEBUG', false);
to
define('CPG_DEBUG', true);

This should show the correct error message why the connection fails.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


DJ Maze wrote
In includes/config.php change
define('CPG_DEBUG', false);
to
define('CPG_DEBUG', true);

This should show the correct error message why the connection fails.


It is set to this--same error.
--Ann

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/PHP Version 5.2.17 MySQL Version 5.5.32-log (client: 5.5.32)/Dragonfly 9.3.4.0


Could you try in includes/config.php
define('DB_TYPE', 'mysqli');

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


I will, thanks.

Meanwhile, I am working with my service provider at the same time. It seems that someone hacked my database and added tables to it up the wazoo...at which point it isn't so much a dragonfly problem but a problem of a corrupted database. (Actually, it kind of would be a Dragonfly problem because there is a security hole somewhere, but I digress...). They are restoring the database from backup, so I'll see if that'll fix it. If not, I'll definitely check the config.php file.

Regardless, I'll let you know what happens so you can make a note of it for future reference.
--Ann

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/PHP Version 5.2.17 MySQL Version 5.5.32-log (client: 5.5.32)/Dragonfly 9.3.4.0


Okay - after 3 days and counting, here is where I am.

My service provider has worked on this with me for hours and hours and they finally came up with the following:

We found that your database table cms_session is the one having all the connections. You are allowed 15 concurrent connections to the database at one time. Somehow that table is not dropping any connections.

This is beyond our troubleshooting with this unfortunately as we are not trained or that familiar with Dragonfly CMS. Your best option would be to contact Dragonfly support as this is more in their realm of specialized support or if you have a web developer that helped you build this site.


Further, on the phone, they said that the calls to this table are being made from the index.php file.

Thanks in advance for any help you can give.
--Ann

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/PHP Version 5.2.17 MySQL Version 5.5.32-log (client: 5.5.32)/Dragonfly 9.3.4.0


Hi Ann "15" connections is way to low!
The MySQL default was 100 and now 151
dev.mysql.com/doc/refm...tions.html

It seems Bluehost is squeezing bandwidth for you.

According to my references there are 1574-2769 neighbours on that IP address.

There are 3 options
  1. Get a better host and pay a bit more then $4.95.mo
  2. Open cPanel and create as many additional DB users as you can. Then in config.php rotate through the users
  3. Use persistent DB connection (not adviced when heavy traffic)

#2 we can help you with, when you have added additional DB users.

The spoof here is that each user is allowed 15 connections, so the more users you have the more connections you have Smile

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial

Last edited by DJ Maze on Sat Jun 29, 2013 10:10 am; edited 2 times in total


Open includes/db/db.php and look for "function sql_close()", you should get:
function sql_close() { if ($this->connect_id && !$this->persistent) { $this->close(); $this->connect_id = false; } }

Now let's try by adding a new function before that one, the final results will be:
function __destruct() { $this->sql_close(); } function sql_close() { if ($this->connect_id && !$this->persistent) { $this->close(); $this->connect_id = false; } }

I do believe you have an error somewhere in footer.php or any file included into it (themefooter(), a block, etc) that is causing db connections not to be closed.

If you have PHP5, this could potentially fix your issue.

Note: After you apply this change you might need to wait up to 8 hours to see if it worked or not as the default mysql wait_timeout is 28800 seconds (8 hours).

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS

All times are UTC


Jump to: