A cPanel admin checks SHOW STATUS LIKE 'Aborted_connects' and sees the number is climbing fast — thousands of aborted connections per hour. The site appears to be working. The customer hasn’t complained. What’s actually happening: someone is trying to brute-force MySQL credentials, or an application has misconfigured its connection pool, or a network device is dropping connections mid-handshake. Each of those reads identically at the counter level. The error log distinguishes them, and the right response is different for each.
What’s happening
MySQL counts an “aborted connect” when a connection attempt failed before reaching the authenticated state. Causes:
- Wrong username or password: client gets “Access denied,” counter increments.
- Authentication plugin mismatch: client doesn’t support the auth method the user requires (
mysql_native_passwordvscaching_sha2_password). - Connection timeout during handshake: client opened TCP but didn’t complete the MySQL handshake in
connect_timeout(default 10 seconds). Common with old clients or slow networks. max_connectionsexceeded: connection refused before authentication, counter increments.- Brute force: a bot trying common credentials.
- Bad client library: some old PHP clients negotiate TLS imperfectly and the server aborts.
Aborted_clients is different — it’s connections that authenticated, then dropped without a clean QUIT. That’s usually client crashes or wait_timeout cutting idle connections, not security relevant.
How to verify
mysql -e "SHOW GLOBAL STATUS LIKE 'Aborted_connects'"
mysql -e "SHOW GLOBAL STATUS LIKE 'Aborted_clients'"
mysql -e "SHOW VARIABLES LIKE 'connect_timeout'"
mysql -e "SHOW VARIABLES LIKE 'log_warnings'"
grep -i "Access denied\|aborted" /var/log/mysql/error.log | tail -20
journalctl -u mariadb --since "1 hour ago" | grep -i "denied\|aborted"
The error log is the diagnostic. log_warnings >= 2 writes aborted-connect details there with the source IP and the reason.
The fix
- Enable detailed logging if not already:
Or persistently in config. Now each aborted connect logs a line with the user, host, and reason.mysql -e "SET GLOBAL log_warnings = 2" - Read the recent aborts:
You’ll see entries like:tail -100 /var/log/mysql/error.log | grep "Aborted"
The reason in parentheses is the clue.[Note] Aborted connection 12345 to db: 'unconnected' user: 'root' host: '203.0.113.99' (Got an error reading communication packets) - For “Got timeout reading communication packets” at high rate from many IPs: brute-force scan. Block at the firewall. CSF should already do this via LFD; check
tail /var/log/lfd.logfor “Login Failure” entries and confirm bans are being applied. - For “Access denied for user” from a small set of IPs and accounts: a legitimate client with bad credentials. Find the client (the user and host are in the log), fix its config.
- For “Got an error reading communication packets” from one IP and one user: network issue or client bug. Check
MTRfrom that IP, checkwait_timeoutsettings on the server (default 28800 seconds), check if the client’s connection pool reuses dropped connections. - For “Too many connections”:
max_connectionsis too low. See the max_connections article. Each refused connection counts as an aborted connect. - For brute force detection:
Shows the source IPs with the most denied attempts. The top of the list is your attacker.awk '/Access denied/ {print $NF}' /var/log/mysql/error.log | sort | uniq -c | sort -rn | head - Block known attacker IPs:
This adds the IP tocsf -d 203.0.113.99 "MySQL brute force"csf.denyand bans it at the kernel firewall. - For long-term defense:
- Reduce
max_connect_errors(default 100) so an IP gets blocked sooner by MySQL’s ownhost_cache. - Add
FLUSH HOSTSto a daily cron if the host_cache fills (rare). - Enable
skip_name_resolve(separate article) — fewer DNS lookups means brute-force scanning is slower. - Move SQL port to a non-standard port if the host is dedicated to one customer (raises attacker effort without breaking legitimate clients you control).
- Reduce
For environments where MySQL is exposed to remote connections and brute-force noise is constant, Stack Harbor’s environment management team tunes CSF/LFD against the abort patterns, monitors the abort rate, and shifts the host’s posture as the threat landscape changes.