And how to unblock with 'mysqladmin flush-hosts'


While working with MySQL, you might have gone through a similar error like this:

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

That error means mysqld has received many interrupted connection requests from the given host. And the number exceeds the value of the max_connect_errors system variable.


For example, the current max_connect_errors value is 10. So if after 10 failed connection requests without a single successful connection, mysqld automatically blocks the host from further connections as a security precaution. It prevents unwarranted access from someone that don’t have proper credentials.


The host is reopened for connection only when you flush the host cache.

Here are some quick fixes:

1. Verify the connection

Check the network connection to make sure that there’s no TCP/IP connectivity issue from your host


2. Increase the value of max_connect_errors

You should find the setting in the MySQL configuration file under the [mysqld] tag (my.ini on Windows, my.cnf on Unix/Linux) and edit the value of max_connect_errors.


For example:

[mysqld]
max_connect_errors=10000


Or run this query:


SET GLOBAL max_connect_errors=10000;

3. Flush host cache


If you have shell access to the server, login and execute this command:

mysql -u root -p -e 'flush hosts'

From the SQL console, run this statement:


FLUSH HOSTS;

If all those methods didn’t work, try restarting the server. It should clear the host cache too.


Need a good MySQL GUI? TablePlus provides a native client that allows you to access and manage MySQL and many other databases simultaneously using an intuitive and powerful graphical interface.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

Need a quick edit on the go? Download for iOS

TablePlus in Dark mode