How can I run a Spring Boot application on port 80
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Spring Boot runs on port 8080 by default, but changing the application to serve on port 80 is easy at the framework level. The real complexity is usually the operating system, because binding to low-numbered ports on Unix-like systems often requires elevated privileges or a safer workaround.
Changing the Spring Boot Port
At the application level, the port change is straightforward. Set server.port=80 in properties, or the equivalent value in YAML.
You can also override it from the command line:
If the process has permission to bind to port 80, the application will start there.
Why Port 80 Can Fail on Linux and macOS
On many Unix-like systems, ports below 1024 are privileged. A normal unprivileged process cannot bind to them directly, so a Spring Boot application launched as a regular user may fail with a permission error even though the configuration is correct.
Running the whole Java process as root is technically possible, but it is usually a poor operational choice. If the application or one of its dependencies is compromised, the process has far more power than it needs.
Recommended Approach: Reverse Proxy
In production, the common pattern is to keep Spring Boot on an unprivileged port such as 8080 and let a reverse proxy listen on 80.
This design is usually better for security and operations. The proxy can also handle TLS termination, compression, access logs, and routing rules, while the Spring Boot process stays unprivileged.
Direct Binding Without Running as root
If you truly want the Java process itself to listen on 80, use a platform-specific mechanism that grants bind permission without full root execution. On Linux, one common option is setcap.
After that, the Java binary can bind to privileged ports such as 80 without running the process as root. This works, but it is still more operationally delicate than a reverse proxy, especially when Java installations are upgraded or managed by a package system.
Some environments also support tools such as authbind, which grant low-port binding for a specific command or user.
Containers and Port Mapping
If the application runs in Docker, you often do not need the process to bind to 80 inside the container. Keep Spring Boot on 8080 internally and publish container port 8080 as host port 80.
That gives clients port 80 access while leaving the application itself on its normal internal port.
Forwarded Headers
When a reverse proxy is involved, the application should understand forwarded headers so links, redirects, and security logic reflect the external request correctly. In Spring Boot, that usually means enabling the correct forward-header strategy for your deployment.
This matters most when the proxy terminates TLS or when the application needs to know the original host and scheme.
Common Pitfalls
Setting server.port=80 in configuration is not enough if the process lacks permission to bind to privileged ports.
Running the entire application as root solves the symptom but creates avoidable security risk.
Forgetting reverse-proxy headers can cause bad redirect URLs, incorrect scheme detection, or broken authentication callbacks.
Granting capabilities to one Java binary and then upgrading Java can silently remove the permission, causing confusing deployment failures later.
Inside containers, many people change the internal application port unnecessarily even though host-port mapping already solves the problem.
Summary
- Spring Boot can be configured to use port
80withserver.port=80. - On Unix-like systems, binding to
80often requires special permission. - The safest production setup is usually a reverse proxy on
80forwarding to Spring Boot on8080. - Direct binding can be done with tools such as
setcap, but it is a more delicate setup. - In containerized deployments, host-port mapping is often the simplest answer.
Related reading
- How can I run bash in a docker container?
- How can I run script automatically after Docker container startup
- How can I see AWS CloudFormation logs in CloudWatch?
- How can I serve static html from spring boot?
- How can I send an email by Java application using GMail, Yahoo, or Hotmail?
- How can I set the JDK NetBeans runs on?
- How can I set the logging level with application.properties?
- How can I set the logging level with application.properties?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.