4
votes

I've installed Jenkins, based on Jetty server on Centos 7. In the configuration file : /etc/sysconfig/jenkins default port is 8080, and everything works perfectly, but I need to move jenkins on 80 port.

When I change JENKINS_PORT="8080" to JENKINS_PORT="80" - jenkins no longer available. Firewall I turned off.

in log messages: /var/log/jenkins/jenkins.log

Aug 17, 2017 12:07:45 PM org.eclipse.jetty.util.log.JavaUtilLog warn
WARNING: FAILED ServerConnector@4082ba93{HTTP/1.1}{0.0.0.0:80}: java.net.SocketException: Permission denied
java.net.SocketException: Permission denied
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:321)
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:366)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at winstone.Launcher.<init>(Launcher.java:152)
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:498)
at Main._main(Main.java:293)
at Main.main(Main.java:132)    

Can anyone help me with that problem?

5

5 Answers

6
votes

Google led me to https://confluence.atlassian.com/confkb/permission-denied-error-when-binding-a-port-290750651.html

Ports below 1024 are called Privileged Ports and in Linux (and most UNIX flavors and UNIX-like systems), they are not allowed to be opened by any non-root user.

So as I run startup script as JENKINS_USER="jenkins" the Permission denied error has appeared.

4
votes

As @Nimda answered https://stackoverflow.com/a/45754065/3471694
I got the same issue below

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:344)
        at Main.main(Main.java:160)
Caused by: java.net.SocketException: Permission denied
        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

Solution: Edit file /etc/sysconfig/jenkins or any jenkins' configuration file
- Change #JENKINS_USER="jenkins" to any user that can run as root
example: JENKINS_USER="root"
Hope this help

1
votes

I struggled for hours with this problem. What i did to solve it eventually was, on Ubuntu, I changed the JENKINS_USER variable value from $NAME to root in /etc/default/jenkins. Then, I did a daemon reload by running the command below.

$ systemctl daemon-reload

Finally, I restarted jenkins as root.

$ service jenkins restart
0
votes

80 is not accessible to non-root user and jenkins is non-root user. I have changes port number and then it worked for me.

-2
votes

Could you try this Centos7 firewall setting?

Don't need to turn off firewall.

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-all

Then starting Jenkins.