When DMS Is Down with the Message 'Host is blocked because of many connection errors MySQL'

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.

To verify TCP/IP connectivity to a host, use ping to test basic reachability and telnet or PsPing to verify specific port access (e.g., 1433 for SQL Server). Ensure the target service is running, firewall rules allow the traffic, and local IP configuration is correct using ipconfig or ifconfig. 

Key Steps to Verify TCP/IP Connection:

a) Ping the Host: Open a command prompt and type ping <hostname/IP> to check if the machine is reachable.

b) Test Specific Port (Telnet/PsPing): Run telnet <hostname> <port> (e.g., telnet 192.168.1.1 1433) to see if a specific application port is open. A blank screen indicates success, while a connection failure indicates a blocked port or service outage.

c) Check Local IP Configuration: Use ipconfig (Windows) or ifconfig (Linux/Mac) to ensure your machine has a valid IP address and can reach the gateway.

d) Verify Service Status: Confirm the destination service (e.g., SQL Server) is running and configured to accept TCP/IP connections.

e) Check Firewalls: Ensure local, network, or cloud firewalls are not blocking the necessary TCP ports.

f) Use netstat: Run netstat -a to display active connections and check for blocked, delayed, or improper connections. 

If ping fails, it suggests a basic network infrastructure issue; if ping works but telnet fails, it indicates a firewall or application-level issue. 

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;

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

Article Details

Article ID:
45
Category:
Rating :

Related articles