When executing
java -jar jenkins-cli.jar -s https://jenkins_url help
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:
Exception in thread "main" java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at hudson.cli.CLI.connectViaCliPort(CLI.java:203)
at hudson.cli.CLI.<init>(CLI.java:126)
at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)
at hudson.cli.CLI._main(CLI.java:466)
at hudson.cli.CLI.main(CLI.java:382)
Suppressed: java.io.EOFException: unexpected stream termination
at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:331)
at hudson.remoting.Channel.<init>(Channel.java:421)
at hudson.remoting.Channel.<init>(Channel.java:400)
at hudson.remoting.Channel.<init>(Channel.java:396)
at hudson.remoting.Channel.<init>(Channel.java:385)
at hudson.remoting.Channel.<init>(Channel.java:377)
at hudson.remoting.Channel.<init>(Channel.java:353)
at hudson.cli.CLI.connectViaHttp(CLI.java:157)
at hudson.cli.CLI.<init>(CLI.java:130)
... 3 more
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:
curl -sI http://jenkins/ | grep CLI
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:
telnet jenkins <cli-port>
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.
I had this issue on Ubuntu 16.04.
Note: this error happened to me well after setting up and having ran successful build jobs before. This happened to me after running a particularly heavy build job. So my fix might work assuming that the error isn't a firewall issue.
First, I tried to do a safe restart through the commandline using the jenkins-cli.jar tool:
java -jar jenkins-cli.jar -s http://localhost:8080 -auth <username>:<password> safe-restart
but also got the same Connection refused error message.
So as a last resort I tried restarting the Jenkins service on the server like so:
sudo systemctl restart jenkins
and that fixed it.
Related
I have created two Web Projects in java.
One of the project was running inside the Tomcat docker container:
192.160.1.5:8080/SocketServer
Another project was running in local machine using eclipse
localhost:8081/SocketClient
I am trying to connect the SocketServer project running inside docker container from the SocketClient using HttpURLConnection in java. But it gives some errors like below:
java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:574)
at java.base/sun.nio.ch.Net.connect(Net.java:563)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:333)
at java.base/java.net.Socket.connect(Socket.java:648)
at java.base/java.net.Socket.connect(Socket.java:597)
at java.base/java.net.Socket.<init>(Socket.java:520)
at java.base/java.net.Socket.<init>(Socket.java:370)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at com.dump.LogAction.startSocket(LogAction.java:61)
at com.dump.LogAction.execute(LogAction.java:37)
How can I resolve this?
This is normal behavior, you should read the docs.
https://docs.docker.com/network/network-tutorial-host/
Quick answer: run the docker image with --network host argument OR you need to expose a port publicly https://www.whitesourcesoftware.com/free-developer-tools/blog/docker-expose-port/ --expose 8080
Scenario :
Recently I have installed SONAR lint v3.4 on Eclipse Oxygen.2 Release (4.7.2
I have SONAR qube server running and I was successfully able to connect SONAR lint to it.
Problem :
However after the connection when I try to take updates from the SONARQUBE server.
Eclipse throws the following error :
Failed to update binding for 1 project,
Unable to update binding for
project 'xyz-project'
Unable to move
C:\Users\vsinghal\eclipse-workspace\.sonarlint\work{SONARQUBE server
domain}\.sonartmp_7415526389500015248\8960528228988360636
to
C:\Users\vsinghal\eclipse-workspace\.sonarlint\storage{SONARQUBE
server domain}\modules\xyz-project
I checked the error log, following is the trace in eclipse :
java.lang.IllegalStateException: C:\Users\vsinghal\eclipse-workspace\.sonarlint\work\{SONARQUBE server domain name}\.sonartmp_7415526389500015248\8960528228988360636 to C:\Users\vsinghal\eclipse-workspace\.sonarlint\storage\{SONARQUBE server domain name}\modules\xyz-project
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.moveDir(FileUtils.java:47)
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.replaceDir(FileUtils.java:153)
at org.sonarsource.sonarlint.core.container.connected.update.perform.ModuleStorageUpdateExecutor.update(ModuleStorageUpdateExecutor.java:63)
at org.sonarsource.sonarlint.core.container.connected.ConnectedContainer.updateModule(ConnectedContainer.java:118)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.updateModule(ConnectedSonarLintEngineImpl.java:260)
at org.sonarlint.eclipse.core.internal.server.Server.updateProjectStorage(Server.java:338)
at org.sonarlint.eclipse.core.internal.jobs.ServerUpdateJob.run(ServerUpdateJob.java:66)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Caused by: java.nio.file.AccessDeniedException: C:\Users\vsinghal\eclipse-workspace\.sonarlint\work\{SONARQUBE server domain name}\.sonartmp_7415526389500015248\8960528228988360636 to C:\Users\vsinghal\eclipse-workspace\.sonarlint\storage\{SONARQUBE server domain name}\modules\xyz-project
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsFileCopy.move(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.move(Unknown Source)
at java.nio.file.Files.move(Unknown Source)
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.moveDirPreferAtomic(FileUtils.java:53)
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.moveDir(FileUtils.java:45)
... 7 more
What did I do try and solve it ?
I gave complete permissions/full control to Everyone for the
eclipse workspace folder in windows explorer .
I tried opening eclipse as admin
I have checked the SONAR server is accessible
but after all these steps the error still doesn't go.
Can anyone help me in finding a solution to this ?
I'm currently experiencing the same issue using SolarLint in both eclipse and Intellij.
There is a reasonable suggestion on google groups, https://groups.google.com/forum/#!topic/sonarlint/nQW1kJBjUYg which suggests that the cause could by a virus scanner interfering in the process. However thus far despite following that theory, I'm still experiencing the issue. Something to try though.
When I use the command prompt in windows to run the command java -jar jenkins.war It is giving me the following error:
SEVERE: Container startup failedjava.io.IOException: Failed to start Jetty
at winstone.Launcher.<init>(Launcher.java:154)
at winstone.Launcher.main(Launcher.java:352)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at Main._main(Main.java:293)
at Main.main(Main.java:132)Caused by: java.net.BindException: Address already in use: bind
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 org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:298)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:431)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at winstone.Launcher.<init>(Launcher.java:152)
... 7 more
The cause of your error:
Caused by: java.net.BindException: Address already in use: bind
Explanation: As a default, Jenkins uses the port 8080 (like many other web applications do, too). Obviously, you already have another application listening on port 8080.
So you should bind Jenkins to another port. See Starting and Accessing Jenkins for more information. For example, you can start with
java -jar jenkins.war --httpPort=8081
cd into your jenkins folder from your terminal(Where you installed it)
cd jenkins
then in your terminal change the port(Whatever port you want to use):
java -jar jenkins.war --httpPort=9090
Jenkins will change ports and restart.And run without any errors.
Load jenkins from your browser:
http://localhost:9090
Also this error sometimes occurs when you have not completed the full installation of jenkins.At the point where jenkins chooses a random browser to continue with installation,just follow along and use the browser its chosen to open and complete the installation following the screen prompts.Once installation is completed,you have the freedom to use whatever browser you see fit.
Another thing to keep in mind is:If you had a previous installation of jenkins before the one you just installed,you need tocheck and ensure all the old jenkins files were deleted and cleaned out of your system before initializing the new installation.
this port is already used in some other services.
you can start jenkins server any port using below command
java -jar jenkins.war --httpPort=8081
After some time (Of idle or after some run launches) the proccess Eclipse.exe is using my specific wanted port.
It obvious that when Java program is running the proccess "javaw" is need to run and this process is using the port (In case of serversocket).
Why does suddenly Eclipse using my port?
So when I running my application I get the predictable exception:
java.net.BindException: Address already in use: JVM_Bind
at java.net.DualStackPlainSocketImpl.bind0(Native Method)
at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
But when I restart Eclipse it release the port
I can't think of a reason why Eclipse would use port 1617. (It is reserved for "Nimrod Inter-agent Communication".)
I suspect that what has happened is that you have used Eclipse to run your application or some unit tests ... within the Eclipse JVM ... and there is a live ServerSocket still hanging around from the tests.
Try restarting Eclipse.
It is also possible that you are using a dodgy plugin which is ignoring the rules on port reservation ... just like your application is doing.
At one point, the remote debug used to work. But for the life of me, I don't seem to be able to figure out what broke it.
I have a flex/Java application. There is a wrapper that starts the tomcat server. I modified the wrapper.conf file to include
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
In my flex debug configurations, on the left, I have Remote Java Application. On the right, I have Standard (Socket Attach) as the connection type, 127.0.0.1 (I have tried localhost too) as Host, and 8000 as Port.
The following is the stack trace.
!ENTRY org.eclipse.jdt.launching 4 113 2013-09-03 11:30:49.109
!MESSAGE Failed to connect to remote VM. Connection refused. !STACK 0
java.net.ConnectException: Connection refused: connect at
java.net.PlainSocketImpl.socketConnect(Native Method) at
java.net.PlainSocketImpl.doConnect(Unknown Source) at
java.net.PlainSocketImpl.connectToAddress(Unknown Source) at
java.net.PlainSocketImpl.connect(Unknown Source) at
java.net.SocksSocketImpl.connect(Unknown Source) at
java.net.Socket.connect(Unknown Source) at
java.net.Socket.connect(Unknown Source) at
java.net.Socket.(Unknown Source) at
java.net.Socket.(Unknown Source) at
org.eclipse.jdi.internal.connect.SocketTransportService$2.run(SocketTransportService.java:136)
at java.lang.Thread.run(Unknown Source)
Here is a screen shot of the debug configurations.
After much struggles, I finally got it figured out. I had to make two changes.
I added tomcat.enable.debug=true to my catalina.properties file.
In my wrapper.conf, I had the following lines.
wrapper.java.additional.9="-Xmx2048m"
wrapper.java.additional.10="-XX:MaxPermSize=1024m"
My MaxPermSize was set to a smaller size than Xmx. I had to change that 1024 to 2048.
I then restarted my tomcat and it worked, finally!
Each debug argument must be placed in a line by itself, after the -vm argument. This should do the trick:
-vmargs
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
Eclipse is not very verbose for this error "Connection refused". One has to check three entries here.
1. Fully qualified host name or IP
2. Correct port number.
3. At Tomcat level heck below:
Some versions of Tomcat has "dt_shmem" entry instead of "dt_socket". Change it to dt_socket in catalina.bat.
The line should looks like this:
set JPDA_TRANSPORT=dt_socket
We must start Tomcat in remote mode rightly, otherwise just setting related variable cannot solve the problem. My solution is below and that works for my situation:
Connection refused problem solution
If you validate Eclipse configuration settings and see that both hostname/IP and port name are correct, try to restart eclipse