Jumat, 21 Maret 2014

How to change Tomcat default port 8080




Tomcat default port is 8080 but many times other Java application also uses 8080 like any other web-server Resin or Jetty and starting tomcat may result in java.net.BindException:Address already in use: JVM_Bind 8080. In order to avoid this exception you can change default port of tomcat from 8080 to some other port e.g. 8081 or 8082. Though don't change to tomcat port which is likely to be used by tomcat itself e.g. 8443 is used by tomcat https port. Use port which is most likely to be free. In this tomcat tutorial we will see how to change default port 8080 for http protocol in tomcat and port 8443 port for https protocol in tomcat.





How to change Tomcat default port 8080



Step by step guide to change tomcat default port 8080



change tomcat default port 8080 for http and httpsHere is step by step guide to change tomcat default port 8080





Step 1:


Find out tomcat server.xml its generally in "C:\Program Files\Apache Software Foundation\Tomcat\conf". This is tomcat installation directory and could be different on your computer based on tomcat version. But important point is server.xml will be inside conf folder





Step 2:


Tomcat uses Connector element to specify port numbers, just locate the relevant Connector element in Server.xml which is configured to listening on port 8080. You can do this by using UNIX grep command on 8080 or simply find following text:






    <Connector port="8080" protocol="HTTP/1.1"


               connectionTimeout="30000"


               redirectPort="8443" />






This Statement is saying that tomcat is listening on 8080 port.





Step 3:


Change default tomcat port from 8080 to 8081 or 8082 in Server.xml file of tomcat






    <Connector port="8082" protocol="HTTP/1.1"


               connectionTimeout="30000"


               redirectPort="8443" />






Now tomcat will listen on Port 8082 instead of deafult port 8080.





4. save your changes on server.xml file and restart tomcat web server. It will start listening on port 8082 instead on default port 8080.





5. Type http://localhost:8082 in your browser you should see tomcat start-up page; it means your tomcat server is configured to listen http traffic on 8082 instead of default 8080.





How to change tomcat default port for SSL or https






Now you know how to change tomcat default port 8080 for http traffic you can also change default ssl port 8443 which is used by https protocol. Just find out relevant section of connector element using grep or find command and change the port from 8443 to 8553 or something else.








How to change default SHUTDOWN Port of Tomcat



Tomcat web server has a concept of SHUTDOWN port, this is the port on which tomcat web-server listen for SHUTDOWN signal. This is another cause of Java.net.BindException: Address already in use: JVM_Bind:8005 because sometime other application also listens on same default SHUTDOWN port 8005.


Just like default tomcat port you can also change tomcat SHUTDOWN port and here is a step by step example





Step: 1 Find out SHUTDOWN Section in Server.xml


Use find or grep command to find word "SHUTDOWN" which will bring you to:






SHUTDOWN"/>






Now just change the SHUTDOWN port from 8005 to any other port you want.





That’s all on how to change tomcat default port from 8080 for both http and https. Let me know if you face any problem while changing default tomcat port.






Related Java Tutorials

































Source:http://javarevisited.blogspot.com/2011/12/how-to-change-tomcat-default-port-8080.html

Tidak ada komentar:

Posting Komentar