简体   繁体   中英

Opening tomcat from the browser on different port than 8080

I have nginx on 8080 port installed on my CentOS server, and I have installed java tomcat additionaly. It's also on 8080 by default, so I changed the port to some free one - 8085. The problem is that trying to get a response from it by opening http://122.21.32.33:8085/ gives me page not found error.

Why is that so?

The service is started, I changed the connector tag in server.xml to:

 <Connector port="8085" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               useIPVHosts="true" />

Firing netstat -ntpl | grep java netstat -ntpl | grep java gives me:

tcp6       0      0 :::8009                 :::*                    LISTEN      8818/java
tcp6       0      0 :::8085                 :::*                    LISTEN      8818/java
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      8818/java

ps -ef | grep tomcat ps -ef | grep tomcat gives me:

tomcat    8818     1  0 17:56 ?        00:00:01 /usr/lib/jvm/jre/bin/java -Djava.security.egd=file:/dev/./urandom -Djava.aw...
root      8862  8144  0 18:00 pts/1    00:00:00 grep --color=auto tomcat

Ports 8818 and 8862 don't work either. What's wrong?

Your netstat-Output says, that you are listening on IPv6. Then you try to connect form your browser via IPv4. You need to configure tomcat to make it listen on IPv4:

You basically have to add this:

JAVA_OPTS= "$JAVA_OPTS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses"

to the end of your catalina.sh file.

Here is a full guide in case you need it.

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