Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi all I'm trying to change the port number of my Tomcat server installed on Ubuntu. For this I have changed the file server.xml and made the following changes:

<Connector port="8081" protocol="HTTP/1.1" 
           redirectPort="8443" />

But the problem is that whenever I try to open the localhost:8081 it is working fine but when I tried to open localhost:8080 but it is still accessible. Can someone please explain why this is happening?

Secondly when I made the default port 80 then tried localhost:80 or localhost then it was not accessible. Again, why is this happening?

share|improve this question

As far as the listener still up on port 8080, you'll want to verify that there isn't a connector defined for that port, and that no other tomcat instances are running.

It's likely that the cause of the issue with port 80 is that low ports require root privileges to bind, and tomcat, by default, runs as a non-root user. The way to get around this is to use authbind.

apt-get install authbind
touch /etc/authbind/byport/80
chown tomcat6:tomcat6 /etc/authbind/byport/80

Then, modify the config file for tomcat to enable authbind support.

nano /etc/default/tomcat6

I believe the setting for authbind is near the bottom of the file.

share|improve this answer
ok thanks. shane madden i will try this – codeomnitrix Mar 3 '11 at 13:46
Hey can you tell me how to check the instances of the tomcat. – codeomnitrix Mar 3 '11 at 13:53
@codeomnitrix ps aux | grep java will give you the running java processes, you're looking for any running under the tomcat6 user. – Shane Madden Mar 3 '11 at 15:12

I tried this solution and it worked for me. All you need to do is to confirm which ports are already in binding then change the port number in the server.xml file of tomcat. Then you need to restart tomcat to make sure change gets implemented.

share|improve this answer
Welcome to Server Fault! Generally we like answers on the site to be able to stand on their own - Links are great, but if that link ever breaks the answer should have enough information to still be helpful. Please consider editing your answer to include more detail. See the FAQ for more info. – slm Jun 12 '13 at 21:17
ok thanks for the info. – Wahib Ul Haq Jun 12 '13 at 21:59

Use redirect iptables rules:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport http -j REDIRECT --to-ports 8081

better not to running Tomcat as root(80 port need root permission).

share|improve this answer
ok thanks ooshro. i will try this one. but it would be better for me if you please explain the above command a bit i mean to ask what the various switches are intended to. actually i am not a professional developer rather a student so. still thanks for your answer – codeomnitrix Mar 3 '11 at 13:49
@codeomnitrix Rahter go the authbind way. There you won't be running as root, but would still be able to have port 80 for your Tomcat. – Juha Laiho May 12 '13 at 20:10

personally I change it in the /srv/apachexxx/conf (or wherever you installed it, inside the conf/ folder) in the file server.xml look for

 <Connector port="8080" protocol="HTTP/1.1" 
               redirectPort="8443" />

and change the port. You also need to change the shutdown ports else you will get a warning, due you cant use same ports (in case you will have more than one tomcat running)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.