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


mysql-error-codeWhen there are many errors when connecting to a mysql server, the following error might appear and the application cannot connect to the db server any more:

Host 'yourhost' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

The above error might appear when the application server and db server are located in different servers.  It also might happen quit frequently when we have db server locates in many nodes (such as replication, sharding, etc.).

How to fix it temporarily?

Of course, run

mysqladmin -u root -p'YourRootPassword' flush-hosts

on the target machine

How to fix it permanently?

Adjust the parameter max_connect_errors in the my.cnf file, and restart the mysqld service. E.g.

...
max_connect_errors=4294967295 # 2^32 - 1
...

We can also create a cron job to flush-hosts periodly 🙂


About NhocConan

A super lazy guy who tries to write tech blog entries in English.He is lazy, so he can only write when he is in a good mood or when he is tired of coding.

Leave a comment

Your email address will not be published. Required fields are marked *