Home > Administration > Changing the default port in Apache Tomcat

Changing the default port in Apache Tomcat

Locate the server.xml file in your %CATALINE_HOME%

Most of the time we don't write code. We configure environments and all kind of tools as a prerequisite. Checking the port used by the Oracle installation or by the Tomcat server in order to setup your Java EE environment is an easy task that can be achieved in a few ways. 

Go to your Tomcat directory\conf and open server.xml

Change the port parameter and save. Note that if you have already imported a server configuration in Eclipse, for example, you will need to refresh it or even change it directly from the properties. 

 

Checking the ports

Checking if a port is open using Telnet

Before doing that, you should check which ports are in use and if there is a conflict at all. The easiest way to check if a port is open is to open the command prompt and use Telnet : 

telnet-check-port

 

Checking the ports which are in use and the related processes with netstat

Unfortunately, Telnet is not installed by default on Windows 7. You can either activate it from Control Panel > Programs and Features > Turn Windows features on or off, or use netstat instead. 

port-check-netstat

netstat -a will list all the currently opened ports with the related remote connections. You can also use the -b option to list the connections along with the processes that have opened them - netstat -ab. Note that you need to start the command prompt as administrator (right-click -> Run as Administrator in Windows 7) or you'll receive a warning message: 
The requested operation requires elevation.

 

Using CPorts to check the ports and the related processes

Another possibility is to use a specific program for that, which provides a nice UI and few additional features, like for example CPorts.ports-check-process

Nice program, very lightweight, no advertisements attached. In my case, tnslsnr.exe (Oracle) was already using the port and that's why the J2EE container was not able to start. 


 


About the author:
Kosta Hristov (34 Posts)

Hi there ! My name is Kosta Hristov and I currently live in London, England. I've been working as a software engineer for the past 6 years on different mobile, desktop and web IT projects. I started this blog almost one year ago with the idea of helping developers from all around the world in their day to day programming tasks, sharing knowledge on various topics. If you find my articles interesting and you want to know more about me, feel free to contact me via the social links below. ;)




Like the article ? Share it ! ;)


  1. Jon
    June 7th, 2013 at 03:37 | #1

    netstat -ab will also show the executable that is using the port

  2. June 7th, 2013 at 15:38 | #2

    Hi Jon, 

    You are right, I've added it to the post. Thanks !

  1. No trackbacks yet.

Current month ye@r day *


Copyright © Developing the future 2013. Licensed under the CC> BY-NC-ND 3.0 Creative Commons license.       
Audi R8 wallpapers Sony Xperia Z4 Tablet WiFi