0

I am trying to run jetty as a service on ubuntu 16.04 on port 8010. It fails with a SocketException: Permission denied.

As far as I know ports above 1024 are free to use, so I'm wondering why I get this error and how to fix it. I had tried port 8080 before, that gave the same error and another one: java.net.BindException: Address already in use: bind. Thats why I changed it to port 8010 which is not in use.

I know ports <1024 need root access, but as far as I know ports above 1024 should be allowed to use without that. So how do I grant my service the right to bind on the port?

This is an extract from the jetty log:

2017-09-28 06:24:57.287:INFO:oejs.AbstractConnector:main: Started ServerConnector@48b22fd4{HTTP/1.1,[http/1.1]}{0.0.0.0:8010}
java.lang.reflect.InvocationTargetException
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 org.eclipse.jetty.start.Main.invokeMain(Main.java:215)
at org.eclipse.jetty.start.Main.start(Main.java:458)
at org.eclipse.jetty.start.Main.main(Main.java:76)

Caused by: java.net.SocketException: Keine Berechtigung
  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)
0

It turned out that jetty was trying to bind to 2 ports: 8010 and 443, although in the log it only showed 8010 with the error.

Changing the the ssl port to something above 1024 solved the issue.

I had tried to give the service full root access, but that still did not allow the service to run on a port below 1024.

1
  • Could be `SELinux`` issue: it may prevent jetty from binding to port.
    – user996142
    Sep 28 '17 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.