I am getting the following errors (in this order) thousands of times in my error log:

[08-Jun-2016 13:11:05 America/Detroit] PHP Warning:  mysqli::stat(): Couldn't fetch mysqli in {...}/libraries/joomla/database/driver/mysqli.php on line 219
[08-Jun-2016 13:11:05 America/Detroit] PHP Warning:  mysqli_close(): Couldn't fetch mysqli in {...}/libraries/joomla/database/driver/mysqli.php on line 226

Here is the function within the mysqli.php file that has lines 219 [if ($this...] and 226 [mysqli_close($this...]:

 * Disconnects the database.
 * @return  void
 * @since   12.1
public function disconnect()
    // Close the connection.
    if ($this->connection instanceof mysqli && $this->connection->stat() !== false)
        foreach ($this->disconnectHandlers as $h)
            call_user_func_array($h, array( &$this));


    $this->connection = null;

I have another Joomla! 3.6.2 site on this server with only a few occurrences of this error one day, so I assume it is a local issue. However, the other site is an exact mirror with a slightly modified theme and fewer extensions, so I am a little confused as to how to proceed.

I did have a few other reference warnings in my theme files. Those have been resolved, but the above warnings continue. I, also, upgraded from PHP 5.4 -> 5.5, but there is no change.

Note 1:

The errors always come in pairs on lines 219 & 226 of mysqli.php. And, they always occur more than 1 pair at a time. Example: On 26-Aug-2016 11:10:25 there were 10 pairs of these errors (20 lines total) at the exact same second.

Note 2:

I ran a Database "Fix", but that did not resolve the issue.

  • What version of MySQL? – Lodder Jun 8 '16 at 18:08
  • This may be related to: issues.joomla.org/tracker/joomla-cms/9511 – Neil Robertson Jun 9 '16 at 4:05
  • @Lodder, I am running MySQL 5.6 – Michael Yaeger Jun 9 '16 at 15:33
  • 1
    @NeilRobertson, I don't have those same issues. However, I did run the Database "Fix" button as suggested, but with no success. – Michael Yaeger Jun 9 '16 at 16:12
  • 2
    I would assume the difference between the problem site and one that rarely gets it would be either 1) An extension only on problem site or 2) the problem site just gets a lot more traffic so the problem occurs more often. Can you reconcile between your two sites and let us know which extensions are on the problem site versus the one that rarely gets it? How does the traffic compare? – YellowWebMonkey Aug 27 '16 at 0:29

If you are using JCH Optimize plugin, you might see these errors. Try to disable the plugin.

  • I am running JCH on this site and a mirror site. The mirror site does not produce these errors (aside from 1 time 2 weeks ago). – Michael Yaeger Aug 26 '16 at 12:18
  • You cannot predict caching from one site to other. Just give it a try to see if it is the issue. you can always enable it again. – Nagarjun Aug 26 '16 at 12:55
  • I am waiting for the next occurrence of the error, then I will be testing without JCH for a few hours to see if the error occurs, again. – Michael Yaeger Aug 26 '16 at 12:58
  • After disabling JCH and clearing the cache, the errors still occur at least once per hour. – Michael Yaeger Aug 26 '16 at 17:24

Have you corrected the database in extensions menu? After upgraded your Joomla?

Extensions -> Database -> Fix button

  • The page shows... "Notice: Database table structure is up to date." – Michael Yaeger Aug 26 '16 at 12:16
  • I tried to run a "Fix", but nothing changed: Database schema version (in #__schemas): 3.6.0-2016-06-05. Update version (in #__extensions): 3.6.2. Database driver: mysqli. 97 database changes were checked successfully. 156 database changes did not alter table structure and were skipped. – Michael Yaeger Aug 26 '16 at 12:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.