Sachin Kainth
Sachin Kainth

Reputation: 46760

Jenkins won't start: Failed to listen on port 8080

I am using Jenkins and since yesterday it has stopped working. I looked at the Windows Service and it had been stopped (somehow). I restarted it but it stopped immediately after.

I have looked in the directory where the service is running from (C:\Program Files\Jenkins) and opened the log file in there called jenkins.out.log. This is what it says

Running from: C:\Program Files\Jenkins\jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
[Winstone 2012/05/17 10:14:42] - Beginning extraction from war file
Jenkins home directory: C:\Program Files\Jenkins found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
[Winstone 2012/05/17 10:14:44] - Winstone shutdown successfully
[Winstone 2012/05/17 10:14:44] - Container startup failed
java.io.IOException: Failed to start a listener: winstone.HttpListener
    at winstone.Launcher.spawnListener(Launcher.java:250)
    at winstone.Launcher.<init>(Launcher.java:202)
    at winstone.Launcher.main(Launcher.java:398)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at Main._main(Main.java:268)
    at Main.main(Main.java:96)
Caused by: java.io.IOException: Failed to listen on port 8080
    at winstone.HttpListener.getServerSocket(HttpListener.java:117)
    at winstone.HttpListener.start(HttpListener.java:70)
    at winstone.Launcher.spawnListener(Launcher.java:241)
    ... 8 more
Caused by: java.net.BindException: Address already in use: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    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)
    at winstone.HttpListener.getServerSocket(HttpListener.java:112)
    ... 10 more

Upvotes: 20

Views: 62670

Answers (11)

Ashu
Ashu

Reputation: 429

If you are upgrading Jenkins which is running on Apache tomcat (Windows) and while installation you are getting below error. So just simply stop the service of Apache and try again. enter image description here

Upvotes: 1

Quickk Care
Quickk Care

Reputation: 51

In case you are using Docker, make sure to specify port using -p option docker run -p 8080:8080 jenkinks/jenkins:latest

Upvotes: 0

abrarcv170
abrarcv170

Reputation: 37

find process id using ps -aux | grep -i 'java' if any java program using the port 8080 you will get following output

jenkins  1236169  246 25.6 7877352 4159028 ?     Sl   04:49 538:57 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080

then kill the process using the command sudo kill -9 PID(here it is 1236169 ) then restart the jenkins service sudo service jenkins restart

Upvotes: 0

Montaser Almohasen
Montaser Almohasen

Reputation: 81

For the Nginx server and SSL certificate, you have to check this documentation from the nginx link and configure the nginx server to listen on port 8080

It worked with me with subdomain like jenkins.your_site_domain.com with port 8080

Upvotes: 1

user735387
user735387

Reputation: 33

putting this here in case it helps someone --I had the same initial problem - port 8080 blocked.

If you can believe this --windows store was running on port 8080 and blocking my Jenkins port. grrr!

Steps to remedy:

1) used @HenryHey's answer above to find the PID: netstat -a -n -o | grep "8080"

2) used sysinternals proc explorer to find what program was registered to the PID

3) used the following command (found article by @Joy-Qiao - thanks) to remove windows store app (use powershell): Get-AppxPackage windowsstore | Remove-AppxPackage

Note: this was a rather drastic approach to clearing port 8080 - a better option would be to just move Jenkins to another port but I was feeling a bit draconic.

Upvotes: 2

Sree Gangireddy
Sree Gangireddy

Reputation: 1

java -jar jenkins.war --ajp13Port=-1 --httpPort=9090

solved my problem

Upvotes: -2

Shariq Muhammad
Shariq Muhammad

Reputation: 11

java -jar jenkins.war --ajp13Port=-1 --httpPort=9090

This is really helpful, that i used when i was facing different exceptions during the installation of Jenkins.

Upvotes: 1

Eugen
Eugen

Reputation: 2990

I had the similar issue, tried to upgrade Jenkins as it was asking, but then it the Windows service won't start, something else was running on port 8080. Turned out was an instance of java.exe process after I killed it in Task Manager all started to work nicely.

Upvotes: 2

AnirbanDebnath
AnirbanDebnath

Reputation: 1043

To start Jenkins on WinStone container(default container bundled with Jenkins war) use the following command:

java -jar jenkins.war --ajp13Port=-1 --httpPort=9090

Also, to check if a certain port is being used by any application use in Windows:

netstat -ano | find "9090"

Its better to run Jenkins on Tomcat.

Upvotes: 20

Sachin Kainth
Sachin Kainth

Reputation: 46760

Fixed - for anyone else who might have this problem in future. I used this Techrepublic article, which boils down to

netstat -a -n -o | grep "8080"

to find out how to find out which process was using port 8080 and then killed it in Task Manager and then restarted Jenkins and all was well (so far!).

Upvotes: 29

Sanjay Singh
Sanjay Singh

Reputation: 41

As in Error Stack Trace it is mentioned that port 8080 is already in use, Check where port 8080 is used or as alternative change the Jenkins Port in Jenkins.xml to some other aviable port.

Upvotes: 4

Related Questions