The moose likes Tomcat and the fly likes Change host name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Change host name" Watch "Change host name" New topic

Change host name

Dominic Steng�rd
Ranch Hand

Joined: Feb 05, 2001
Posts: 186
Hey Tomcat Gurus!

How do I change the host name of a Tomcat server?
The problem Im having is that Ive got several development environments and they all have their own names. I want these environment names to be reflected by the respective Tomcat installations as well.

For example on my local installation I might want to be able to access my webapps using a different URL such as:

Im guessing that this setting is set in server.xml ... but I cant get it to work as expected.

Kind regards

Dominic Steng�rd<br />Sun Certified Java 2 Programmer
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15087

It's not really possible to create separate hostnames for different applications or different Tomcat installations on the same server.

The hostname is the name of the computer itself in the IP network, it is not something that is configured in Tomcat. The name "localhost" is a special hostname, which is hardwired to the IP address, which always means "this computer".

If you want your computer to have a different hostname on the network, then you must configure the DNS (Domain Name Service) server which translates hostnames to IP addresses, but this is usually not something you can do yourself (your Internet service provider or network administrator can do this for you).

If you want to use alternative hostnames locally only (only on the computer itself, not useable when you connect from another computer), then you can edit the file C:\Windows\System32\drivers\etc\hosts. Add a line like this, for example:

and then you can connect via http://mymachine:8080

But note that you cannot use this to separate webapps or Tomcat installations with different names.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Change host name
It's not a secret anymore!