Introduction When Jenkins build agents go offline, queued builds cannot execute and CI/CD pipelines stall. Agent disconnections are caused by network issues, JVM problems, or Jenkins controller configuration.

Symptoms - Jenkins UI shows agent as "Offline" with red indicator - Build queued but stuck: "Waiting for next available executor" - Agent log shows: "Connection closed" or "JNLP connection lost" - Agent reconnects but disconnects again after a few minutes - All builds on the specific agent fail

Common Causes - Network interruption between controller and agent - Agent JVM crashed (OOM, OutOfMemoryError) - JNLP port not accessible through firewall - Agent JAR file corrupted - Controller load causing agent disconnects

Step-by-Step Fix 1. **Check agent status in Jenkins UI**: Manage Jenkins > Manage Nodes > Check agent status and offline reason.

  1. 1.Restart the agent:
  2. 2.```bash
  3. 3.# For SSH agents
  4. 4.ssh <agent-host> "sudo systemctl restart jenkins-agent"
  5. 5.# For JNLP agents, restart the agent process
  6. 6.java -jar agent.jar -jnlpUrl http://<jenkins>/computer/<agent>/slave-agent.jnlp
  7. 7.`
  8. 8.Check agent JVM memory settings:
  9. 9.```bash
  10. 10.# On agent host
  11. 11.ps aux | grep agent.jar
  12. 12.# Check for OOM in system logs
  13. 13.dmesg | grep -i oom
  14. 14.`

Prevention - Configure agent auto-reconnect with retry settings - Monitor agent connectivity with health checks - Use SSH agents instead of JNLP for more reliable connections - Set appropriate JVM heap size for agent processes - Implement agent health monitoring and alerting