How to Fix 'Agent Not Found' Error in Jenkins
The
agent not found error in Jenkins happens when the master cannot find or connect to the specified agent node. To fix it, verify the agent is properly configured, online, and the label matches the job's requirements.Why This Happens
This error occurs because Jenkins cannot locate or communicate with the agent node assigned to run the job. Common reasons include the agent being offline, misconfigured, or the job requesting a label that no agent has.
groovy
pipeline {
agent { label 'nonexistent-agent' }
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
}
}Output
ERROR: No agent found with the label 'nonexistent-agent'.
The Fix
Ensure the agent node is online and connected to Jenkins. Check the agent's label matches the one used in the pipeline. If the label is wrong, update it to a valid one or change the pipeline to use an existing label.
groovy
pipeline {
agent { label 'valid-agent' }
stages {
stage('Build') {
steps {
echo 'Building on valid agent...'
}
}
}
}Output
[Pipeline] echo
Building on valid agent...
[Pipeline] End of Pipeline
Prevention
Keep agent nodes online and properly labeled. Regularly check agent status in Jenkins dashboard. Use consistent labels and avoid typos in pipeline scripts. Automate agent health checks if possible.
Related Errors
- Agent offline: Agent is disconnected or shut down. Fix by restarting the agent.
- Label mismatch: Job requests a label no agent has. Fix by correcting labels.
- Authentication failure: Agent cannot authenticate with master. Fix credentials.
Key Takeaways
Verify the agent node is online and connected to Jenkins.
Match the pipeline agent label with an existing agent's label.
Regularly monitor agent status to avoid unexpected disconnections.
Use consistent and correct labels in pipeline scripts.
Restart or reconfigure agents if authentication or connection fails.