HowToDoInJava

  • Python
  • Java
  • Spring Boot
  • Dark Mode
Home / Tomcat / How to run Tomcat on port 80

How to run Tomcat on port 80

By default, Tomcat is configured to run on port 8080. That’s why all the deployed web applications are accessible though URLs like http://localhost:8080/yourapp.

If you want to run an application on URL like http://localhost/yourapp, then you will need to change the default port 8080 to 80, which is default port for HTTP connectors.

1. Change port to 80 in tomcat’s server.xml

To make this port change, open server.xml and find below entry :

<Connector port="8080" 		//Change this
			protocol="HTTP/1.1"
			connectionTimeout="20000"
			redirectPort="8443" 
/>

and change it to below entry:

<Connector port="80" 		//Changed !!
		protocol="HTTP/1.1"
		connectionTimeout="20000"
		redirectPort="8443" 
/>

You are all set to access your applications using root path “http://localhost/“.

2. Changing port in Linux

In linux, port upto 1024 are reserved ports. So, to use any port below this (e.g. port 80 in our case), we must make additional configuration changes.

2.1. With root access

This one is easy. Simply start the Tomcat process as root.

sudo startup.sh

2.2. Without root access

If we do not have root access, we must install and configure authbind package. It helps in binding sockets to privileged ports without root.

  • Install authbind.
    sudo apt-get install authbind
    
  • Enable authbind in server.xml.
    AUTHBIND=yes
    
  • Configure tomcat in authbind if permission denied error comes (EPERM – Operation not permitted, or Not owner), use these command to enable access.
    sudo touch /etc/authbind/byport/80
    sudo chmod 500 /etc/authbind/byport/80
    sudo chown tomcat8 /etc/authbind/byport/80
    
  • At last, restart the tomcat server if it is running already.

Happy Learning !!

Was this post helpful?

Let us know if you liked the post. That’s the only way we can improve.
TwitterFacebookLinkedInRedditPocket

About Lokesh Gupta

A family guy with fun loving nature. Love computers, programming and solving everyday problems. Find me on Facebook and Twitter.

Feedback, Discussion and Comments

  1. shubham

    November 14, 2019

    any other option without change in server.xml.I dont want my port will show in url .Mail me as soon as possible.

  2. Jpp67

    March 19, 2015

    Yes, this will probably not be very useful, too basic. Why not to change the redirect port by the time ?
    The real point about this topic is how to manage this under Linux/UNIX as the 1024 first ports require special privileges. Regards

  3. mauro

    March 19, 2015

    HI .i have read your article for run tomcat on port 80.
    But i have read from many web sites that the first 1024 port are reserved and not usable .
    Is only for linux ?

    I know that so i not have to put a apache like front end for redirect at port 8080 .

    Let me know please .
    Tank you for all your beatiful articles.
    Mauro

    • Lokesh Gupta

      March 20, 2015

      Yes, restriction is linux specific. Regarding port 80, it’s default for HTTP so you should be able to use it without any issue irrespective of underlying OS.

Comments are closed on this article!

Search Tutorials

Tomcat Tutorials

  • Tomcat – Architecture
  • Tomat – Default Port
  • Tomcat – Disable Directory Listing
  • Tomcat – SSL Configuration
  • Tomcat – Run Multiple Instances
  • Tomcat – Maven Plugin
  • Get Real IP Behind Load Balancer
  • How web servers work?

Meta Links

  • About Me
  • Contact Us
  • Privacy policy
  • Advertise
  • Guest and Sponsored Posts

Recommended Reading

  • 10 Life Lessons
  • Secure Hash Algorithms
  • How Web Servers work?
  • How Java I/O Works Internally?
  • Best Way to Learn Java
  • Java Best Practices Guide
  • Microservices Tutorial
  • REST API Tutorial
  • How to Start New Blog

Copyright © 2020 · HowToDoInjava.com · All Rights Reserved. | Sitemap

  • Sealed Classes and Interfaces