Support » Plugins and Hacks » [Resolved] Too Many MySQL connections

[Resolved] Too Many MySQL connections

  • Our ISP has detected a huge amount of MySQL errors being generated by the Wordfence plugin.

    So many in fact that they have asked us to remove it as our error file has racked up to 12MB in under 2 hours.

    Here’s a sample of the error messages:
    [Thu Nov 29 03:03:36 2012] [error] [client 107.21.*.*] PHP Warning: mysql_connect() [function.mysql-connect]: User [removed] already has more than ‘max_user_connections’ active connections in /home/sites/[removed]/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 56

    [Thu Nov 29 03:03:36 2012] [error] [client 107.21.*.*] PHP Warning: mysql_ping() expects parameter 1 to be resource, boolean given in /home/sites/[removed]/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 48

    That goes on pretty much every few tenths of a second.

    Are the MySQL connecitons being closed and managed properly in your private function connectHandle() method?

    How many times are you calling mysql? You also seem to be using mysql_ping which even PHP discourages use of.

    Why do you need to make so many mysql connections? What info are you reading/writing to the DB?

    Can’t you use WP Transients for that?



Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Wordfence


    Hi Wil,

    Wordfence makes it’s own connection to the DB and hosts that have “max_user_connections” set very low see this issue.

    Tell your host to increase “max_user_connections” and try again.

    We use our own connection because it gives us higher performance than using wpdb.

    Transients are for caching.



    Thanks for the response @mmaunder

    We’re on shared hosting for this particular site so I have no control over the max_user_connection and they won’t increase it.

    About transients, I was just wondering if you could use them to store some info rather than polling the DB.

    Any-ho, here’s the warnings from the server error log. At the very least they should help you put in some more error catching.

    [Thu Nov 29 03:03:36 2012] [error] [client ***.***.***.***] PHP Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/sites/***.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 57

    [Thu Nov 29 03:03:36 2012] [error] [client ***.***.***.***] PHP Warning: mysql_ping() expects parameter 1 to be resource, boolean given in /home/sites/***.com/public_html/wp-content/plugins/wordfence/lib/wfDB.php on line 48


    @mmaunder can you suggest a minimum max_user_connections setting to use with your plugin?

    Our host has come back with their setting of max_user_connections=25.

    They will not change this.

    Why this post have status resolved, i hav ethe same problem, and i can’ increase number of connections, what should i do in this case ?



    Forum Moderator

    @esmi – why post a new topic when the Plugin Author wrongly resolved an unresolved thread?

    The observation it’s corect …the problem it’s not resolved !



    Forum Moderator

    Are you using the same version of WordPress on the same physical server hosted by the same hosts with the same plugins, theme & configurations as the original poster?

    No? Then your problem – despite any similarity in symptoms – is likely to be completely different. So please help us to help you and post a new topic when we ask you to.

    @esmi – could you use your moderator powers to mark this thread as unresolved?



    Forum Moderator

    Sorry but no. If you didn’t mark this topic as resolved then the plugin author must have done so. And I am not willing to over-ride his decision. If you are still having problems, I suggest you open a new topic.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Resolved] Too Many MySQL connections’ is closed to new replies.