Skip to content
Latchkey

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.

jenkins
Cannot contact agent-7: java.lang.InterruptedException
Could not connect to agent-7 to send interrupt signal to process

Common 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

  1. Check controller and agent logs for the contact-loss window.
  2. Add retry around the affected stage so a transient loss re-runs.
Jenkinsfile
retry(2) { sh 'make test' }

Reduce agent overload

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

Frequently asked questions

What causes ""Cannot contact agent""?
The remoting ping timed out due to a slow or dropped network path.
How do I fix "Cannot contact agent"?
Diagnose and retry

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card