I want to execute my web app as http://localhost
.

- 16,038
- 10
- 74
- 104

- 2,283
- 5
- 23
- 33
-
This might help you http://www.digizol.com/2008/06/tomcat-how-to-change-port-8080.html – lkamal Nov 09 '13 at 12:28
14 Answers
1) Go to conf
folder in tomcat installation directory
e.g. C:\Tomcat 6.0\conf\
2) Edit following tag in server.xml
file
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
3) Change the port=8080
value to port=80
4) Save file.
5) Stop your Tomcat and restart it.
-
14
-
3I did this and I get a 404 error! Is there anything else I should be doing? – Saturnian Jul 20 '14 at 11:35
-
15In `etc/default/tomcat7` set `AUTHBIND=yes`, to avoid a PermissionDenied error for the port 80. – Markus Pscheidt Jan 26 '15 at 08:20
-
1
-
This answer lacks the /etc/authbind information, see answer from Rose below – jorfus Mar 09 '16 at 04:28
-
URL rewriting for outbound rules 'll resolve it. If you change tomcat port to 80 then other websites on iis may get affected. – SNMohanty Nov 21 '20 at 09:00
Ubuntu 14.04 LTS, in Amazon EC2. The following steps resolved this issue for me:
1. Edit server.xml and change port="8080" to "80"
sudo vi /var/lib/tomcat7/conf/server.xml
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
2. Edit tomcat7 file (if the file is not created then you need to create it)
sudo vi /etc/default/tomcat7
uncomment and change #AUTHBIND=no to yes
3. Install authbind
sudo apt-get install authbind
4. Run the following commands to provide tomcat7 read+execute on port 80.
sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown tomcat7 /etc/authbind/byport/80
5. Restart tomcat:
sudo /etc/init.d/tomcat7 restart
-
1That one works. Linux people, at least works for me with Ubuntu 14.04.2 LTS. – Rodrigo Gurgel Feb 04 '16 at 00:16
-
3Autobind is the correct answer. But note that you can skip autobind in case you are using 'sudo startup.sh' since port 80 will be granted to escalated user. – Marcio Jasinski Mar 11 '16 at 11:17
-
1Thanks!! I knew about enabling authbind in server config but didn't know I had to create a file in authbind for registered port! I wish OP had changed the accepted solution to this answer! (I see that you were almost 3 years late in answering :P) – Fr0zenFyr Mar 18 '17 at 06:49
-
1It works with Tomcat 9 on Lubuntu 18.0.4, without installing `authbind`, only adding the setting. – Marco Sulla Jul 05 '19 at 12:37
-
On a Linux Debian-based (so Ubuntu included) you have also to go to /etc/default/tomcat7
, uncomment the #AUTHBIND=no
line and set its value to 'yes', in order to let the server bind on a privileged port.

- 21,536
- 6
- 60
- 80

- 1,308
- 3
- 12
- 11
-
3
-
-
I also had the issue that the file didn't exist. I started a new machine with reinstall and it appeared... – Abby Jan 01 '14 at 19:27
-
7Doesn't work for Tomcat if installed by zip/tar.gz, as they don't create the file in /etc/defaults/. – Gorkamorka Jan 06 '14 at 21:00
-
9That path above should be: /etc/default/tomcat7 (note the lack of 's' in default) – Tristan Reid Jan 17 '14 at 22:53
-
I had to take the additional steps outlined in Rose's answer as well to get this to work on ubuntu – aw04 Mar 15 '16 at 19:31
-
3
-
@katu It's the same, but the line does not exists, commented or not, you have to add it. – Marco Sulla Jul 05 '19 at 12:35
On Ubuntu and Debian systems, there are several steps needed:
In server.xml, change the line
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
to haveport="80"
.Install the recommended (not required) authbind package, with a command like:
sudo apt-get install authbind
Enable authbind in the server.xml file (in either
/etc/tomcat6
or/etc/tomcat7
) by uncommenting and setting the line like:AUTHBIND=yes
All three steps are needed.

- 1,252
- 1
- 15
- 23
-
6
-
4To get it to work from zip/tar.gz, do steps 1 and 2 above, add AUTHBIND=yes to bin/setenv.sh (create if not there) and start from root. Works with LTS 12.04, should also work w/13.10. – karl Mar 28 '14 at 14:31
-
In my case it failed (with no error message in catalina.out) without the authbind package, worked after installing it – golimar Apr 01 '14 at 15:33
-
Could you please point to the documentation about AUTHBIND=yes? I find it nowhere. – ARX Dec 20 '17 at 14:47
-
I cannot find a mention of the AUTHBIND setting as part of the server element configuration in the TOMCAT documentation either. Strange. – Peter N. Steinmetz Dec 23 '17 at 00:25
-
-
The authbind package was a recommended, rather than required, package in Ubuntu at the time. It is needed for the server.xml configuration to work. You can check if it is installed with 'pkg -s authbind' – Peter N. Steinmetz Jul 09 '19 at 01:05
I tried changing the port from 8080
to 80
in the server.xml
but it didn't work for me. Then I found alternative, update the iptables
which i'm sure there is an impact on performance.
I use the following commands:
sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo /sbin/service iptables save
http://www.excelsior-usa.com/articles/tomcat-amazon-ec2-advanced.html#port80

- 5,628
- 5
- 36
- 53

- 579
- 5
- 12
-
-
1Run the following command to remove the routing: iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 – casol Apr 03 '18 at 23:26
As previous answers didn't work well (it was good, but not enough) for me on a 14.04 Ubuntu Server, I mention these recommendations (this is a quote).
Edit: note that as @jason-faust mentioned it in the comments, on 14.04, the authbind
package that ships with it does support IPv6 now, so the prefer IPv4 thing isn't needed any longer.
1) Install authbind
2) Make port 80 available to authbind (you need to be root):
touch /etc/authbind/byport/80
chmod 500 /etc/authbind/byport/80
chown tomcat7 /etc/authbind/byport/80
3) Make IPv4 the default (authbind does not currently support IPv6).
To do so, create the file TOMCAT/bin/setenv.sh with the following content:
CATALINA_OPTS="-Djava.net.preferIPv4Stack=true"
4) Change /usr/share/tomcat7/bin/startup.sh
exec authbind --deep "$PRGDIR"/"$EXECUTABLE" start "$@"
# OLD: exec "$PRGDIR"/"$EXECUTABLE" start "$@"
If you already got a setenv.sh
file in /usr/share/tomcat7/bin
with CATALINA_OPTS
, you have to use :
export CATALINA_OPTS="$CATALINA_OPTS -Djava.net.preferIPv4Stack=true"
Now you can change the port to 80
as told in other answers.

- 3,399
- 3
- 36
- 46
-
2I would add that the startup.sh file is located at: /usr/share/tomcat7/bin/startup.sh - Its not completely obvious to us newbies ;) – ConMan Jul 23 '14 at 20:20
-
@ConMan updated paths, that's a great idea to save other searchs. I admit that knowing this place is not obvious in the beginning. – smonff Jul 24 '14 at 07:35
-
1Thanks, this worked great, I'm used to centos, so this was helpful to me, where this was not an issue for me. – med116 Sep 06 '15 at 18:24
-
1I just followed this today on 14.04, the authbind package that ships with it does support IPv6 now, so the prefer IPv4 thing isn't needed any longer. – Jason Faust Dec 02 '15 at 17:09
-
On modern linux the best approach (for me) is to use xinetd :
1) create /etc/xinet.d/tomcat-http
service http
{
disable = no
socket_type = stream
user = root
wait = no
redirect = 127.0.0.1 8080
}
2) create /etc/xinet.d/tomcat-https
service https
{
disable = no
socket_type = stream
user = root
wait = no
redirect = 127.0.0.1 8443
}
3) chkconfig xinetd on
4) /etc/init.d/xinetd start

- 77
- 1
- 4
-
Other approach is to compile and use jsvc but xinetd is definitely easier – cgdave Mar 07 '14 at 22:14
If someone is looking for, how to change the tomcat port number in Eclipse IDE user following are the steps.
1.In the Servers view, double click on the server name:
2.That will open a configuration page for Tomcat as follows:
3.Notice the port numbers are shown in the table on the right. Click to edit, for example:
4.That will change port number for HTTP from 8080 to 80. Press Ctrl + S to save the change and restart the server. We can spot the change of port number in the Console view:
This all content were taken from below link, please refer that link for further information thanks. http://www.codejava.net/servers/tomcat/how-to-change-port-numbers-for-tomcat-in-eclipse

- 689
- 2
- 6
- 19
Running the command below worked with. Tried changing server.xml
and the conf file but both didn't work.
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
/sbin/iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

- 3,399
- 3
- 36
- 46

- 385
- 2
- 5
On a linux server you can just use this commands to reconfigure Tomcat to listen on port 80:
sed -i 's|port="8080"|port="80"|g' /etc/tomcat?/server.xml
sed -i 's|#AUTHBIND=no|AUTHBIND=yes|g' /etc/default/tomcat?
service tomcat8 restart

- 2,135
- 25
- 16
if you are using eclipse and modifying server.xml doesn't work for you then try following article.. they have steps to modify port if you are using IDE like eclipse.

- 33
- 5
Just goto conf folder of tomcat
open the server.xml file
Goto one of the connector node which look like the following
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Simply change the port
save and restart tomcat

- 5,920
- 2
- 19
- 18
Here are the steps:
--> Follow the path: {tomcat directory>/conf -->Find this line:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
change portnumber from "8080" to "80".
--> Save the file.
--> Restart the server :)

- 435
- 2
- 9
- 26
Don't forget to edit the file. Open file /etc/default/tomcat7
and change
#AUTHBIND=no
to
AUTHBIND=yes
then restart.