1

I am using tomcat8 and i have changed http port in cofg/server.xml as

In http connector i have changed port 8080 to 80

< Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

I have restarted tomcat but i have got this error

apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1  11 Sep 2018]
18-Jun-2019 18:20:46.933 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-80"]
18-Jun-2019 18:20:46.961 SEVERE [main] org.apache.catalina.core.StandardService.initInternal Failed to initialize connector [Connector[HTTP/1.1-80]]
 org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-80]]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:113)

Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
        at org.apache.catalina.connector.Connector.initInternal(Connector.java:996)
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
        ... 12 more
Caused by: java.net.SocketException: Permission denied
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:461)

Please anyone help me how to start tomcat8 on port 80. I have above erroe after changing port inside server.xml

Anuj Dhiman
  • 1,550
  • 3
  • 26
  • 51
  • 1
    Possible duplicate of [How to change the port of Tomcat from 8080 to 80?](https://stackoverflow.com/questions/4756039/how-to-change-the-port-of-tomcat-from-8080-to-80) – Ori Marko Jun 20 '19 at 13:49
  • @user7294900 after etc/default/tomcat7 set AUTHBIND=yes i am able to run tomcat on port 80 but now i am calling url http://ipaddress/ApplicationPath , then i got Connection timed out in browser i have also set authbind . If i have run curl command inside server like curl http://ipaddress/ApplicationPath then it give me can u tell me correct response .Please help me what is this issue – Anuj Dhiman Jun 20 '19 at 14:45

1 Answers1

1

Port 80 is a privileged port. You have a few options:

  • Use a proxy like haproxy to bind to port 80 then forward to tomcat 8080
  • Use authbind to give permission to tomcat to bind to port 80
  • Use iptables kernel redirect from 80 to 8080

The second and third are [marginally] better performance since they happen in the kernel, but you'd only see any sort of latency or throughput increase in really really busy servers

Jonathan S. Fisher
  • 8,189
  • 6
  • 46
  • 84