Tomcat configuration HTTPS error Java net. SocketException: Permission denied
1. Error message
Today, when configuring HTTPS certificate for tomcat, an error was reported when starting Tomcat:
25-Jan-2022 22:01:59.398 SEVERE [main] org.apache.catalina.core.StandardService.initInternal Failed to initialize connector [Connector[HTTP/1.1-443]]
org.apache.catalina.LifecycleException: Protocol handler initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:1060)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:552)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:848)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
at org.apache.catalina.startup.Catalina.load(Catalina.java:639)
at org.apache.catalina.startup.Catalina.load(Catalina.java:662)
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.apache.catalina.startup.Bootstrap.load(Bootstrap.java:303)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
Caused by: java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:438)
at sun.nio.ch.Net.bind(Net.java:430)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:225)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:221)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1118)
at org.apache.tomcat.util.net.AbstractJsseEndpoint.init(AbstractJsseEndpoint.java:223)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:587)
at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:74)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:1058)
... 13 more
The reason for the error is: java.net.Socketexception: permission denied
, which is obviously a network permission problem. The reason for this problem is that the Linux operating system does not allow non root users to use ports less than 1024.
2. Solutions
1. Use the root account to start Tomcat
2. Change the port number to a port number greater than 1024, but add the port number to the URL request
3. Change the port number to a port number greater than 1024, and use iptables to forward port 443 to the configured port. The command is as follows:
#Execute the commands under the root
# Mapping port 443 to 8443
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443
Read More:
- [Solved] port (127.0.0.1:64444): java.net.SocketException “Interrupted function call: accept failed“
- java.net.SocketException: software caused connection abort: socket write error resolution (selenium)
- [Solved] hadoop Error: 9000 failed on connection exception java.net.ConnectException Denied to Access
- [Solved] Multithreading uses jsch to obtain a session for connection error: session.connect: java.net.socketexception: connection reset
- [Solved] XxlJob Error: XxlJobFileAppender [101] -| Permission denied
- [Solved] Rocketmq Root Account Startup Error: Permission denied
- [Solved] Error: caused by: java.net.bindexception: the address is already in use
- [Solved] Activity jump permission UID Error: ActivityTaskmanager: Permission Denied
- [Solved] failed on connection exception: java.net.ConnectException: Connection denied
- Resolve warning: could’t clear Tomcat cache java.lang.NoSuchFieldException: resourceEntries
- JAVA Error Illegal access: this web application instance has been stopped already. Could not load net.sf
- [Solved] java.security.AccessControlException: Access Denied Error
- [Solved] Docker Run Tomcat Error: Cannot find /usr/local/tomcat/bin/setclasspath.sh
- [Solved] kafka Error: java.net.UnknownHostException: ls-bptysztw
- [Solved] openstack4j Startup Error: java.net.UnknownHostException: controller
- [Solved] tomcat Startup Error: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
- How to Solve Springboot YML configurate logging.level error
- [Solved] Hadoop failed on connection exception: java.net.ConnectException: Connection refused
- jemter java.net.BindException:Address alreardy in use [How to Solve]
- [Solved] JAVA HttpClient Send Https request certificate error:PKIX path building failed: