Communications link failure Java Origin: Application & API Last updated 13 Oct 2026

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The MySQL JDBC driver couldn’t reach the database (or the connection dropped).

Exact message you may see Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago
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

  1. Verify the JDBC URL and that MySQL is reachable (telnet host 3306)
  2. Use the service name in containers
  3. Configure the pool (HikariCP maxLifetime < wait_timeout)

Detailed fix by platform

Java

  1. spring.datasource.hikari.max-lifetime=1700000

How to diagnose

  1. Last packet — 0 ms (never connected) or large (dropped)?
  2. Network — Reachable from the app host?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

1040 — MySQL ERROR 1040 (08004): Too many connections (MySQL)10401049 — MySQL ERROR 1049 (42000): Unknown database 'x' (MySQL)10492002 — MySQL ERROR 2002 (HY000): Can't connect to local MySQL server through socket (MySQL)20022003 — MySQL ERROR 2003 (HY000): Can't connect to MySQL server on 'host:3306' (111) (MySQL)20032006 — MySQL ERROR 2006 (HY000): MySQL server has gone away (MySQL)20062013 — MySQL ERROR 2013 (HY000): Lost connection to MySQL server during query (MySQL)2013could not find driver — PDOException: could not find driver (PHP)could not find driverHikariCP timeout — HikariPool-1 - Connection is not available, request timed out after 30000ms (Java)HikariCP timeoutCommunica…

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.