TCP port for inbound agents is already in use

Article ID:115003564051
2 minute readKnowledge base


  • Agents cannot connect to Jenkins

  • controller 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 port <PORT>. Change the port number Address already in use
    at Method)
    at hudson.TcpSlaveAgentListener.<init>(
Caused: Failed to listen on port <PORT> because it's already in use.
    at hudson.TcpSlaveAgentListener.<init>(
    at jenkins.model.Jenkins.launchTcpSlaveAgentListener(
    at jenkins.model.Jenkins.<init>(
    at hudson.model.Hudson.<init>(
    at hudson.model.Hudson.<init>(
    at hudson.WebAppMain$
  • Agent logs show:

INFO: Locating server among [<CONTROLLER_URL>]
Nov 26, 2017 10:17:40 PM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: <CONTROLLER_URL>/tcpSlaveAgentListener/ is invalid: 404 Not Found <CONTROLLER_URL>/tcpSlaveAgentListener/ is invalid: 404 Not Found
                at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(
                at hudson.remoting.Engine.innerRun(
  • An Administrative Monitor reads:

Failed to listen to incoming agent connections


Most likely, you would experience this issue if another application already uses the port configured for inbound agents. In that case, Jenkins disables the port. Also, new agents cannot reconnect.

How to diagnose

Identify the port advertised by Jenkins

You can confirm whether or not the TCP port is configured for the controller by running the following:

$ curl -IL <CONTROLLER_URL>/tcpSlaveAgentListener/

If the TCP port for inbound agents is correctly configured, this command should return 200 and the header x-jenkins-jnlp-port with the value of the port.

Identify the application that listens to that port

You can check which application is listening on the port <PORT> with the following commands:

$ netstat -ntlp | grep <PORT>


$ lsof -i tcp -n -P | grep <PORT> | grep LISTEN

These commands help you to identify the process ID (PID) that is listening to a particular port. You can then learn more about the process with the command:

> ps -p <PID>
these commands may require to sudo


Different applications must listen on different ports in the same host. The solution is to change the Jenkins TCP port for inbound agents or change the port that the other application is using.

If you observe this issue after a restart, it most likely means that the old process did not release its resources properly. In this situation, you first need to make sure the old process is really dead. Then you can switch the 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.