Skip to content
Tickwise
ErrorDatabasesSIG-DB-005

Stale MySQL connections (The last packet successfully received … milliseconds ago)

Platforms
Paper · Purpur · Velocity · single server
Verified
Verified
Confidence
Confidence 80%

What it looks like in the log

Any one of these lines is enough. The agent matches them locally, on your server.

logs/latest.log
  • [WARN] The last packet successfully received from the server was

Symptoms

  • Plugin queries fail intermittently after idle periods: CommunicationsException with “The last packet successfully received from the server was N milliseconds ago”

Cause

The MySQL driver used a connection that the database server or the network in between had already closed for being idle: the connection lifetime in the pool is longer than the database's wait_timeout or the NAT/firewall idle timeout.

Possible causes

  • The pool's maxLifetime (HikariCP, 30 min by default) is longer than the database's wait_timeout — the server closes idle connections before the pool does
  • A NAT/firewall/database proxy drops connections on an idle timeout (N is noticeably lower than wait_timeout)
  • The database was restarted or connections were killed manually (KILL) while the server was running

How to fixLow risk

  1. Find the database timeout: SHOW VARIABLES LIKE 'wait_timeout'; (seconds).
  2. In the plugin config, set the pool's maxLifetime at least 30 seconds below wait_timeout (for LuckPerms — pool-settings.maximum-lifetime, in milliseconds).
  3. If there is a NAT/firewall with a short idle timeout between the server and the database, enable the pool's keepaliveTime (e.g. 60000 ms) and keep maxLifetime below that timeout.
  4. Do not rely on autoReconnect=true as the main fix — the pool should replace old connections itself.

Translated from the Russian original; log lines are quoted verbatim.

Sources