Randa ElBehery
Randa ElBehery

Reputation: 167

I Can't start Jenkins in background (Address already in use)

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

Upvotes: 0

Views: 1833

Answers (2)

Randa ElBehery
Randa ElBehery

Reputation: 167

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

Upvotes: 0

SachinPatil4991
SachinPatil4991

Reputation: 774

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.

Upvotes: 1

Related Questions