Which Port Should Spring Boot Web Server Run On?


Scott Campbell

When developing a Spring Boot application, one important consideration is determining which port the web server should run on. The default port for a Spring Boot application is 8080, but there are several factors to consider before deciding whether to stick with the default or choose a different port.

Why Change the Default Port?

The default port, 8080, is widely used and may already be occupied by another application running on your machine. In such cases, you need to choose a different port to avoid conflicts. Additionally, if you plan to deploy your application on a cloud platform or in a containerized environment, you may be required to use a specific port range defined by the platform.

How to Change the Port

To change the default port in Spring Boot, you can utilize either application.properties or application.yml file. These files allow you to configure various properties for your application, including the server.port property.

Using application.properties:

  • Create an application.properties file in your project’s src/main/resources directory if it doesn’t already exist.
  • Add the following line to specify the desired port:

Using application.yml:

  • Create an application.yml file in your project’s src/main/resources directory if it doesn’t already exist.
  • Add the following lines to specify the desired port:
  port: 8888

Tips for Choosing a Port Number

When choosing a port number, it is advisable to consider the following:

  • Avoid common port numbers: Choose a port number that is not commonly used by other applications. Common port numbers include 80 (HTTP), 443 (HTTPS), and 8080 (default for many web servers).
  • Stay within the dynamic and private port range: The dynamic and private port range is from 49152 to 65535. Selecting a port within this range reduces the chances of conflicts with other applications.


In summary, choosing the appropriate port for your Spring Boot web server is crucial to avoid conflicts and ensure smooth operation. By following the steps outlined above, you can easily change the default port to a more suitable one.

Remember to consider factors such as existing application conflicts and platform requirements when selecting a new port. Happy coding!

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy