Skip to content


Host ‘patheticcockroach.com’ is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’

Just got this pretty annoying error on a setup where the database isn’t on the same machine as the web server. As mentioned in the error message, running this flush-hosts command works (although you actually have to add connection parameters, resulting in a command such as mysqladmin -u root -p flush-hosts). BUT, apparently, if you do nothing (for instance, if you don’t notice the error), your server remains locked, which can be quite problematic, to say the least.

I didn’t really have the time to dig into the possible reasons for this problem yet, but a first fix is simply to increase MySQL’s tolerance to connection errors. To do this, you just need to edit the configuration file (on Debian 6, /etc/mysql/conf.d/my.cnf) to add something like max_connect_errors = 500 under the [mysqld] section. This is the maximum number of connection errors that the server will accept before locking itself (default: 10). I’m still wondering whether or not this is a grand total or a per day/hour/something count, though.

After that, don’t forget to apply the configuration changes:
/etc/init.d/mysql reload

(on a side note, to see the current mysql version: mysql --version)

Sources:

Posted in MySQL.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA