Troubleshoot: “host is blocked because of many connection errors.”

It takes place usually when connections end prematurely, for example with a TCP socket error or when there have been many errors trying to connect your MySQL server. That’s a security option, because, you may have malicious users trying to connect your database many times to guess root password, or it may be a network problem.

But while trying to find out what’s happening you can’t have your website offline, so the first thing is logging your server and doing:

$ mysqladmin flush-hosts -uroot -p[root password]

and then try to see mysql logs. It’s interesting to have a look a this information:

$ mysql -uroot -p[root password]
mysql> show status like ‘%abo%’;
+——————+——-+
| Variable_name | Value |
+——————+——-+
| Aborted_clients | 120 |
| Aborted_connects | 20 |
+——————+——-+

Where Aborted clients are unexpected ended connections, or connections opened successfully but never closed properly (network problems, software problems…), I found out it happened when my developing computer was connected to the database and I turned it off, the database was not closed and then the connection was dropped.

Aborted connects are those unsuccessfully opened connections, or users trying to connect with wrong password or wrong protocol.

But if your mysql server is isolated, listening only on localhost or filtering by IP, or behind a VPN you shouldn’t worry about that, make sure there is no network problem (if you connect with localhost, it may be a software problem), just rise up the number of total error connections by sending this command:

mysql>SET GLOBAL max_connect_errors=100000;
Query OK, 0 rows affected (0.04 sec)

Or by creating a new line on your my.cnf with this text under mysqld directive:

max_connect_errors=100000

Leave a Reply

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