- Agents cannot connect to Jenkins
- Master logs show:
2017-11-27 05:47:40.670+0000 [id=57] WARNING jenkins.model.Jenkins#launchTcpSlaveAgentListener: Failed to listen to incoming agent connections through JNLP port <JNLP_PORT>. Change the JNLP port number java.net.BindException: Address already in use at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:433) at sun.nio.ch.Net.bind(Net.java:425) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67) at hudson.TcpSlaveAgentListener.<init>(TcpSlaveAgentListener.java:96) Caused: java.net.BindException: Failed to listen on port <JNLP_PORT> because it's already in use. at hudson.TcpSlaveAgentListener.<init>(TcpSlaveAgentListener.java:98) at jenkins.model.Jenkins.launchTcpSlaveAgentListener(Jenkins.java:1241) at jenkins.model.Jenkins.<init>(Jenkins.java:937) at hudson.model.Hudson.<init>(Hudson.java:86) at hudson.model.Hudson.<init>(Hudson.java:82) at hudson.WebAppMain$3.run(WebAppMain.java:235)
- Agent logs show:
INFO: Locating server among [<MASTER_URL>] Nov 26, 2017 10:17:40 PM hudson.remoting.jnlp.Main$CuiListener error SEVERE: <MASTER_URL>/tcpSlaveAgentListener/ is invalid: 404 Not Found java.io.IOException: <MASTER_URL>/tcpSlaveAgentListener/ is invalid: 404 Not Found at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:167) at hudson.remoting.Engine.innerRun(Engine.java:499) at hudson.remoting.Engine.run(Engine.java:451)
- An Administrative Monitor reads:
Failed to listen to incoming agent connections through JNLP
- CloudBees CI (CloudBees Core) on traditional platforms - Client Master
- CloudBees Jenkins Platform - Client Master
- CloudBees Jenkins Distribution
- Jenkins LTS
Most likely, you would experience this issue if an application is already using the port that is configured for JNLP.
In that case, Jenkins disables the JNLP port.
This results in agents connection drops.
Also new agents cannot reconnect.
Identify the port advertised by Jenkins
You can confirm whether or not the JNLP port is configured for the master by running:
curl -IL <MASTER_URL>
If the JNLP port is correctly configured, this command should return the header
X-Jenkins-JNLP-Port with the value of the JNLP port.
Identify the application that listen to that port
You can check which application is listening on the port
<PORT> with the following commands:
netstat -ntlp | grep
lsof -i tcp -n -P | grep
| grep LISTEN
These commands helps you to identify the process ID (
PID) that is listening to a particular port. You can then know more about the process with the command:
Note: these command may require to
Different application must listen on different port in the same host.
The solution is to change Jenkins JNLP port or change the port that the other application is using.
In case you observe this issue after a restart, it most likely means that the old process did not release properly its resources.
In this situation, you first need to make sure the old process is really dead.
Then you can switch the JNLP port to a dummy value (say if your chosen port is 50000, choose 50001), then hit apply and switch back to the proper port.
This will force Jenkins to bind again to the port.
If this is not enough, then restart your instance.