Jenkins error: java.net.ConnectException: Connection timed out (Connection timed out)
Jenkins error: java.net.ConnectException: Connection timed out (Connection timed out)
I have installed jenkins on aws ec2 instance and I am not able to connect the jenkins slave with the master. Below is the error I am getting,
[email protected]***:~/jenkins# java -jar agent.jar -jnlpUrl http://13.243.79.109:8080/computer/Worker2Of2ndInstance/jenkins-agent.jnlp -secret @secret-file -workDir "/root/jenkins" Jan 15, 2021 4:29:48 AM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir INFO: Using /root/jenkins/remoting as a remoting work directory Jan 15, 2021 4:29:48 AM org.jenkinsci.remoting.engine.WorkDirManager setupLogging INFO: Both error and output logs will be printed to /root/jenkins/remoting Failed to obtain http://3.243.79.109:8080/computer/Worker2Of2ndInstance/jenkins-agent.jnlp?encrypt=true java.net.ConnectException: Connection timed out (Connection timed out) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:607) at java.net.Socket.connect(Socket.java:556) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:463) at sun.net.www.http.HttpClient.openServer(HttpClient.java:558) at sun.net.www.http.HttpClient.<init>(HttpClient.java:242) at sun.net.www.http.HttpClient.New(HttpClient.java:339) at sun.net.www.http.HttpClient.New(HttpClient.java:357) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1226) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:990) at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:511) at hudson.remoting.Launcher.run(Launcher.java:345) at hudson.remoting.Launcher.main(Launcher.java:296) Waiting 10 seconds before retry
vito Selected answer as best September 21, 2021
Check if the IP address in the java jar command is as per the current IP of your ec2 instance. The IP shown in the java jar command should be of your master instance. It happens that when you restart your instance, the public IP changes. If the IP is not as per the current IP of your instance in the java jar command, then you will have to update the Jenkins URL. Follow the below steps to do the same,
Manage Jenkins > Configure System > Jenkins URL > change the IP as per the current IP of your instance > Save
Now copy the java jar command again and execute it in the slave instance.
vito Selected answer as best September 21, 2021