Skip to content

Aborted_connects climbing on a cPanel MySQL host — what each cause looks like

A spike in Aborted_connects can mean failed authentication, network drops, client misconfig, or a brute-force scan. Reading the right log distinguishes them in seconds.

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_password vs caching_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_connections exceeded: 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

  1. Enable detailed logging if not already:
    mysql -e "SET GLOBAL log_warnings = 2"
    Or persistently in config. Now each aborted connect logs a line with the user, host, and reason.
  2. Read the recent aborts:
    tail -100 /var/log/mysql/error.log | grep "Aborted"
    You’ll see entries like:
    [Note] Aborted connection 12345 to db: 'unconnected' user: 'root' host: '203.0.113.99' (Got an error reading communication packets)
    The reason in parentheses is the clue.
  3. 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.log for “Login Failure” entries and confirm bans are being applied.
  4. 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.
  5. For “Got an error reading communication packets” from one IP and one user: network issue or client bug. Check MTR from that IP, check wait_timeout settings on the server (default 28800 seconds), check if the client’s connection pool reuses dropped connections.
  6. For “Too many connections”: max_connections is too low. See the max_connections article. Each refused connection counts as an aborted connect.
  7. For brute force detection:
    awk '/Access denied/ {print $NF}' /var/log/mysql/error.log | sort | uniq -c | sort -rn | head
    Shows the source IPs with the most denied attempts. The top of the list is your attacker.
  8. Block known attacker IPs:
    csf -d 203.0.113.99 "MySQL brute force"
    This adds the IP to csf.deny and bans it at the kernel firewall.
  9. For long-term defense:
    • Reduce max_connect_errors (default 100) so an IP gets blocked sooner by MySQL’s own host_cache.
    • Add FLUSH HOSTS to 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).

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.