简体   繁体   中英

Cannot start Jenkins on port 80 on debian 7

I have installed Jenkins on debian 7. Now I would like to run it on port 80 so I can simply type http://jenkins on my local LAN instead of http://jenkins:8080 (which currently works). I have modified the file /etc/default/jenkins to:

# port for HTTP connector (default 8080; disable with -1)
#HTTP_PORT=8080
#HTTP_PORT=88
HTTP_PORT=80

But when I restart the jenkins service: sudo service jenkins restart and try to access http://jenkins:80 I just get a blank/error page. The log says ( /var/log/jenkins/jenkins.log ):

java.io.IOException: Failed to start a listener: winstone.HttpListener
    at winstone.Launcher.spawnListener(Launcher.java:229)
    at winstone.Launcher.<init>(Launcher.java:181)
    at winstone.Launcher.main(Launcher.java:384)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at Main._main(Main.java:288)
    at Main.main(Main.java:98)
Caused by: java.io.IOException: Failed to listen on port 80
    at winstone.HttpListener.getServerSocket(HttpListener.java:122)
    at winstone.HttpListener.start(HttpListener.java:75)
    at winstone.Launcher.spawnListener(Launcher.java:220)
    ... 8 more
Caused by: java.net.BindException: Permission denied
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:353)
    at java.net.ServerSocket.bind(ServerSocket.java:336)
    at java.net.ServerSocket.<init>(ServerSocket.java:202)
    at java.net.ServerSocket.<init>(ServerSocket.java:158)
    at winstone.HttpListener.getServerSocket(HttpListener.java:117)
    ... 10 more
Sep 11, 2013 9:09:30 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Sep 11, 2013 9:09:30 PM hudson.WebAppMain$3 run
SEVERE: Failed to initialize Jenkins
java.lang.InterruptedException
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:502)
    at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:244)
    at jenkins.InitReactorRunner.run(InitReactorRunner.java:43)
    at jenkins.model.Jenkins.executeReactor(Jenkins.java:906)
    at jenkins.model.Jenkins.<init>(Jenkins.java:806)
    at hudson.model.Hudson.<init>(Hudson.java:81)
    at hudson.model.Hudson.<init>(Hudson.java:77)
    at hudson.WebAppMain$3.run(WebAppMain.java:221)
Exception in thread "pool-2-thread-1" java.lang.NullPointerException
    at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:191)
    at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:94)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:679)

I have tried to run sudo netstat -lp but don't see any port info (does not look like any application is runnning on port 80). I have also tried with port=88 but it gives the same result.

Any suggestions?

I have the same problem, and I found out that you can't listen to ports below 1024 without root privileges.

There are couple of things we can do but I think the safest one is:

  • Redirect port 80 to 8080 with iptables

# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

Besides that, you can run jenkins as root, by chown and chmod but I think that can be dangerous.

The other possibilites are covered here:

https://serverfault.com/questions/112795/how-can-i-run-a-server-on-linux-on-port-80-as-a-normal-user

makek sure that apache or something else is not running on port 80 with

netstat -utanp | grep 80

tcp 0 0 :::80 :::* LISTEN 1428/httpd

if anything else is running on 80 make sure you stop it before starting Jenkins on 80

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM