0

I am running jenkins using

java -jar jenkins.war -httpPort=31114

and it starts correctly, Now I am trying to run it in background, I found it can be done using nohup java -jar jenkins.war -httpPort=31114 & as mentioned here Start Jenkins in the background.

But when I terminate the session I started at the beginning and try to run it in background on the same port, I get the following error:

SEVERE: Container startup failed
java.io.IOException: Failed to start Jetty
    at winstone.Launcher.<init>(Launcher.java:186)
    at winstone.Launcher.main(Launcher.java:354)
    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:498)
    at Main._main(Main.java:375)
    at Main.main(Main.java:151)
Caused by: 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 org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:339)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:307)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:395)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at winstone.Launcher.<init>(Launcher.java:184)
    ... 7 more
Randa ElBehery
  • 167
  • 2
  • 17
  • Check whether that particular port is already in use,using this: netstat -tulpn | grep 31114. If yes then kill the process using sudo kill -9 PID and try to start again. – Coder Apr 03 '19 at 09:06
  • There is no process using this port – Randa ElBehery Apr 03 '19 at 09:19
  • Refer this, you might get some help: https://stackoverflow.com/questions/34342207/jenkins-update-error-java-net-bindexception-address-already-in-use – Coder Apr 03 '19 at 09:51

2 Answers2

1

Caused by: java.net.BindException: Address already in use

It means jenkins already running on given port or some other process is using that port.

netstat -nltp Use this command to check all open ports. Kill process if jenkin allready running on that port or if other process is using that port you can run jenkins on other port.

Below commnd you have used is correct . May be you have hit it twice .

nohup java -jar jenkins.war -httpPort=31114 & 

ps -ef | grep jenkins. To check if jenkins is already running.

SachinPatil4991
  • 774
  • 6
  • 13
  • I have tried using different ports that doesn't appear in `netstat` output and it gives the same error. but when I try to run it in the fore ground on the port 31114 it starts correctly – Randa ElBehery Apr 03 '19 at 08:37
  • Not sure why you are getting error. Can you try settin port in Jenkins.xml configuration file – SachinPatil4991 Apr 03 '19 at 08:47
0

I tried adding the command nohup java -jar jenkins.war --httpPort=31114 & to a bash file and run the file, it worked

Randa ElBehery
  • 167
  • 2
  • 17