Pages

Tomcat default port is 8080 but many times other Java application also uses 8080 like any other web-server Resin or Jetty and starting tomcatmay result in java.net.BindException:Address already in use: JVM_Bind 8080. In order to avoid this exception you can changedefault 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

Here 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 installationdirectory 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 configuredto 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

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 orfind 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 causeof 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:

<Server port="8005" shutdown="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.

3 comments
:

Roshni
said...

hi I want my tomcat 6 to execute web application on http://localhost, I don't want to type 8080 again and again , is there any way I can do this ? I read somewhere that I can do this by changing the default port of tomcat 6 to 80 but as soon as I did this by following your method I got Java.net.BindException: Address already in use: JVM_Bind:80 , What should I do now ,please suggest ?

Another method you can use is iptables. iptables let you forward traffic received on one port (80) to another port (8080). This method bypasses the Apache webserver completely (even if it is running on port 80). This is the simple to setup. But you will not be able to use Apache (e.g. for webmail, using PHP apps, or apps like phpMyAdmin)