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

<!-- ==================== Connectors ==================== -->
 
<!-- Normal HTTP -->
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
    <Parameter name="handler" 
        value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
    <Parameter name="port" 
        value="8080"/>
</Connector>

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. 


 



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.


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