com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The MySQL JDBC driver couldn’t reach the database (or the connection dropped).
Seen on:
Java
Meaning
“The last packet sent successfully to the server was 0 milliseconds ago” means it never connected: wrong host/port, DB down, firewall, or SSL negotiation issues. Non-zero means an idle connection was dropped.
Common causes
- Wrong host/port or DB not running
- Docker: localhost instead of service name
- Firewall/security group
- Idle connections killed (wait_timeout)
- SSL/useSSL mismatch
⚡ Quick fix
- Verify the JDBC URL and that MySQL is reachable (telnet host 3306)
- Use the service name in containers
- Configure the pool (HikariCP maxLifetime < wait_timeout)
Detailed fix by platform
Java
spring.datasource.hikari.max-lifetime=1700000
How to diagnose
- Last packet — 0 ms (never connected) or large (dropped)?
- Network — Reachable from the app host?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026