Jenkins "Cannot contact agent" InterruptedException
The controller could not reach the agent, so it interrupted the build with an InterruptedException. The connection became unresponsive mid-run.
What this error means
A running stage stops with "Cannot contact agent" followed by a java.lang.InterruptedException. The agent may reconnect later, but the build already failed.
Cannot contact agent-7: java.lang.InterruptedException
Could not connect to agent-7 to send interrupt signal to processCommon causes
Transient network unresponsiveness
The remoting ping timed out due to a slow or dropped network path.
Agent overloaded
High CPU or memory pressure made the agent stop responding to the controller.
Agent host paused or reclaimed
A VM pause, spot reclaim, or container eviction broke contact.
How to fix it
Diagnose and retry
- Check controller and agent logs for the contact-loss window.
- Add retry around the affected stage so a transient loss re-runs.
retry(2) { sh 'make test' }Reduce agent overload
- Lower executors per agent or add memory so the agent stays responsive.
How to prevent it
- If you run on GitHub Actions, self-healing managed runners such as Latchkey auto-retry transient failures, so a lost-contact blip does not fail the job. On Jenkins, tune executor counts and monitor agent load.