Skip to content
Advertisement

Jenkins CLI connection refused

When executing

JavaScript

I’m getting connection refused for some reason. Jenkins version is 1580.3, user has the permissions on Jenkins server, cli jar is up-to-date and ssh public key is configured properly. Any idea what might be causing this? Here’s the stack trace if it will help:

JavaScript

Advertisement

Answer

If the connection is refused, perhaps the CLI is disabled, but more likely there’s a firewall or network issue.

Each successful HTTP request to Jenkins responds with the CLI port as an HTTP header, so you can quickly check whether it’s enabled:

JavaScript

Alternatively, as documented on the wiki, you can check whether the TCP port is enabled. Look for “TCP port for JNLP slave agents” at http://jenkins/configureSecurity/

However, since your stacktrace indicates that the CLI client is trying to establish a connection to a particular port, it suggests that the CLI is enabled, and Jenkins is advertising that port number in its HTTP responses.

So you could try to connect to that port manually, to check whether it’s open:

JavaScript

If you also see “Connection refused” here, then you know that your Jenkins and CLI client setup seem to be ok, but you have a network issue. In which case, check that the firewall on the Jenkins server allows incoming connections on that CLI port.

To make firewall configuration easier, you can switch from a random port to a fixed port in the “configure security” page mentioned above.

Advertisement