How to change Tomcat default port ?

Tomcat by default runs on port number 8080, However there is high chance get a port conflict with others program. Sometime we just need to change the Tomcat port number.

Steps of changing the Tomcat Port

1) Locate server.xml in {Tomcat installation folder}\ conf \

2) Find following similar statement

 <!-- Define a non-SSL HTTP/1.1 Connector on port 8180 -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />

or

    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />

3) About Tomcat’s server.xml file cites it’s runs on port 8080. Change the Connector port=”8080″ port to any other port number.

For example

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

Above statement instruct Tomcat server runs on port 8181.

4) Edit and save the server.xml file. Restart Tomcat. Done

Tags :

About the Author

mkyong
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

  • Pingback: keylogger()

  • Pingback: k7x()

  • Pingback: how can i win the lottery()

  • Pingback: Orange County()

  • Pingback: locksmiths perth 24 hour service()

  • Pingback: mining kalgoorlie()

  • Pingback: commercial window cleaner()

  • Pingback: AR15 rifle kit()

  • Pingback: http://blackjackonline.us.org/()

  • Pingback: serviced office Meeting Room Hire()

  • Pingback: Shoe cleaner and conditioner()

  • Pingback: paintless dent repair()

  • Pingback: http://www.menage-poly.com()

  • Pingback: www.miniclip.com()

  • Pingback: internet radio retailers uk()

  • Pingback: Google()

  • imran

    thank you verry much .so solved my unending problems……

  • http://claytonpret.wetpaint.com/page/Joann+Fabrics+Printable+Coupons+-+Working+Coupons Joann Fabrics coupon codes

    Hello I am so glad I found your weblog, I really found
    you by mistake, while I was looking on Google for something else, Regardless I am here now and would just like to say thanks a lot
    for a remarkable post and a all round entertaining blog (I also love the theme/design), I don’t have time to go through it all at the moment but I have saved it and also added in your RSS feeds, so when I have time I will be back to read more, Please do keep up the great work.

  • http://www.slideshare.net/bryangillbq/vxb-coupon-get-a-coupon-now Vxb This coupon

    My coder is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using WordPress on
    a number of websites for about a year and am anxious about switching to another platform.
    I have heard great things about blogengine.net. Is there a way I can import all my
    wordpress content into it? Any kind of help would be greatly appreciated!

  • http://ihart.bolerotech.org/JacquesN6 douglas

    Hi there are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started and create
    my own. Do you require any coding expertise to make your own blog?
    Any help would be greatly appreciated!

  • cons

    Thanks for the article. But I wonder if it’s possible “not to give any port number”???
    I mean:
    At the beginning, My port was like:
    http://localhost:8080/
    <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"
    I could change the 8080 port to 8181 e.g. but it didn't work when I try not to set any.. like this:
    <Connector port="" protocol="HTTP/1.1" connectionTimeout="20000"
    It gives me this error:

    Access forbidden!

    ——————————————————————————–

    New XAMPP security concept:

    Access to the requested directory is only available from the local network.

    This setting can be configured in the file "httpd-xampp.conf".

    ——————————————————————————–
    Do you have any idea about not to set any port?
    Thanks..

    • Ronald

      Buenas, tengo el mismo problema, si lo llegastes a solucionar, me podrias indicar cual fue la solucion.!!!!!!!!!!!!!! Muchas gracias de antemano

  • clara

    thank u so much.it is now working properly.

  • Rakesh K Satyam

    Thanks

  • Vijaya

    Great! Thanks a lot for your effort and help.

  • Pingback: How to change Port Number Of Http Server in either Oracle10g or tomcat? - Admins Goodies()

  • Jomblick J

    Should we change shutdown port also? what is the purpose of that shutdown port ??

  • Shivam

    thanks a lot. Its working properly……

  • rahul

    thanks a lot, it is working very fine.

  • siva

    great….but not working for me….iam encountering some more problems……pls help me

  • ildolce

    Hi.

    I have a problem.
    I’ve changed the port in server.xml because I have this port with other application.
    I start tomcat server from catabalina.bat perfect in the new port.
    I change the port for tomcat in XAMP.INI with the new port.
    Restart the computer.
    And I try again to start tomcat server from XAMP console but I see log as “Busy port – Tomcat 8080″.
    The tomcat server start but I want to avoid this message in the xamp console.

    What Can I do?

  • Ruby

    Nice tutorial. I love your site..
    Some more similar tutorial that may help others
    http://www.raistudies.com/tomcat/change-port-number-of-tomcat-server/

    Thank You

  • http://www.servletworld.com servletworld

    Nice tutorial, This tutorial explains how to change the HTTP port, shutdown port and AJP port http://www.servletworld.com/tomcat/howto-change-tomcat-port.html

  • Rakesh

    thanks its useful to beginners

  • Echo

    you have to also change the shutdown port…

    • http://www.mkyong.com mkyong

      Sorry, what you mean by “shutdown” port?

  • Madhu

    Thanks

  • http://www.fundooad.com saurabh

    Very useful comment. i was looking for changing Tomcat Port and got the response.

    thanks

    • dhirendra

      thanks