I have a LEMP stack project that is hosted on digital ocean. that shows error
Host '167.71.227.200' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
every day i use FLUSH HOSTS;
otherwise it give me same error.
what should i do to solve it permanently.
i’m not to digital host and ops in general.
2
Answers
This is likely because you have frequent errors when clients try to connect to your MySQL Server. See https://dev.mysql.com/doc/refman/8.0/en/host-cache.html#blocked-host
It’s tempting to increase the value of
max_connect_errors
, but that will only delay the problem slightly. The fact that your server is seeing so many errors probably indicates a root cause that you need to address another way.For example, this could be caused by an unstable network between the client and the MySQL Server, so connection attempts frequently fail. You should improve the network reliability, or else move the client to a host that has a more stable network.
This is likely not a code problem, but an infrastructure problem.
You are forgetting to close the database connection in your application.
Use conn.close() to ensure the connection is closed after each query