How do I resolve the "Host is blocked because of many connections errors" error in Amazon RDS for MySQL?

3 minute read
0

I want to resolve the blocked host error that I receive when connecting to an Amazon Relational Database Service (Amazon RDS) DB instance.

Short description

Your Amazon RDS for MySQL server maintains an in-memory host cache that contains client hostname and IP address information. This information is used to avoid Domain Name System (DNS) lookups for each client connection. The cache also contains information about errors that occur during the client connection process. If too many errors occur from a host without a connection, then the server blocks further connections from that host with the following error:

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

The value of the max_connect_errors parameter determines how many successive interrupted connection requests that the server permits before blocking a host. When max_connect_errors fail requests without a successful connection, the server blocks the host from further connection requests. For more information, see max_connect_errors on the MySQL website.

If a connection from a host is successfully established after a previous failed connection request, then the host error count is set to zero.

Resolution

To resolve the error and unblock blocked hosts, complete the following steps:

Note: Before you increase the max_connect_errors parameter, use flush hosts commands, or reboot the RDS for MySQL instance, check the TCP/IP connections. If there are network issues, then you receive the host is blocked error message.

1.    Run one of the following commands to flush the host cache. For more information, see Flushing the host cache on the MySQL website.

  • Use an existing DB connection and flush the host cache:
FLUSH HOSTS;
  • Connect from another Amazon Elastic Compute Cloud (Amazon EC2) client machine and flush the host cache:
mysqladmin -h <example_RDS_endpoint_URL> -P <example-port> -u <example-user> -p flush-hosts

Note: Replace all instances of example strings with your required values.

mysqladmin -h <example_RDS_endpoint_URL> -P <example-port> -u <example-user> -p flush-hosts

2.    Use the Custom Parameter Group to increase the max_connect_errors parameter. For more information, see Working with parameter groups.

3.    When downtime is available, reboot the RDS for MySQL instance. To prevent an increased recovery time, make sure that you don't have any long running transactions or a High DML workload before you reboot.

Related information

Best practices for configuring parameters for Amazon RDS for MySQL, part 3: Parameters related to security, operational manageability, and connectivity timeout

The host_cache table on the MySQL website

Dealing with blocked hosts on the MySQL website

AWS OFFICIAL
AWS OFFICIALUpdated 9 months ago