Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
LemonWiki共筆
Search
Search
Appearance
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Troubleshooting of MySQL errors
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Resolving "Host 'xx.xx.xxx.xxx' is blocked because of many connection errors" === Error Message <pre> Host 'xx.xx.xxx.xxx' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' </pre> Understanding the Issue (1) Check the threshold value MySQL's mechanism works as follows: once the same source host (identified by IP or hostname) accumulates a number of "connection errors" reaching the value configured in `max_connect_errors`, MySQL automatically blocks that source and refuses further connections from it. <pre> SHOW VARIABLES LIKE 'max_connect_errors'; </pre> The threshold found was 100. (2) Check which hosts are currently recorded/blocked <pre> SELECT IP, HOST, SUM_CONNECT_ERRORS, COUNT_HOST_BLOCKED_ERRORS FROM performance_schema.host_cache ORDER BY SUM_CONNECT_ERRORS DESC; </pre> Confirmed that the only blocked IP is `xx.xx.xxx.xxx`, with `SUM_CONNECT_ERRORS` exactly matching the threshold of 100, and no other IPs were affected. Resolving the Issue ⚠️ Note: `flush-hosts` / `FLUSH HOSTS` clears the **entire** host cache, not just a single IP. If the query results show records for other hosts as well, they will all be reset at the same time. For a shared production environment, it's recommended to confirm with other administrators before running this. (1) In a terminal or command prompt, run: <pre> mysqladmin -u root -p flush-hosts </pre> or <pre> mysql -u root -p Once inside the MySQL shell, run: FLUSH HOSTS; </pre> Note: The `FLUSH HOSTS` syntax has been deprecated since MySQL 8.0.23 and removed in 8.4<ref>[https://dev.mysql.com/doc/refman/8.4/en/performance-schema-host-cache-table.html MySQL :: MySQL 8.4 Reference Manual :: 29.12.22.3 The host_cache Table]</ref><ref>[https://oneuptime.com/blog/post/2026-03-31-mysql-fix-max-connect-errors-blocked-hosts/view How to Fix max_connect_errors and Blocked Hosts in MySQL]</ref>. If your environment is on a newer version, use the officially recommended alternative instead: <pre> TRUNCATE TABLE performance_schema.host_cache; </pre> (2) Verify after execution <pre> SELECT IP, HOST, SUM_CONNECT_ERRORS, COUNT_HOST_BLOCKED_ERRORS FROM performance_schema.host_cache ORDER BY SUM_CONNECT_ERRORS DESC; </pre> Result: no rows returned (0 rows), indicating the host cache has been cleared — the previous connection error counts and blocked status have been reset, and the IP should now be able to connect normally.
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki共筆:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)