Why Spring Boot uses Port 8080?

  1. Default Configuration in Spring Boot:

    • Spring Boot applications are configured to run on port 8080 by default. This is a convention that allows developers to start applications quickly without having to change the configuration files for a commonly used and available port.
  2. Avoiding Conflicts:

    • Port 80 is the default for HTTP traffic, and it's often already in use by web servers like Apache or Nginx on a machine. By using port 8080, Spring Boot applications can be run alongside these web servers without requiring additional configuration or causing conflicts.
  3. Permission Requirements:

    • On many operating systems, especially Unix-like ones, using a port number below 1024 requires elevated privileges (root access). By defaulting to port 8080, Spring Boot avoids the need for such permissions, making it easier for development and testing.
  4. Common Practice:

    • Port 8080 is widely used by developers for development and testing purposes. It has become a de facto standard for non-production environments, which makes it a familiar choice for many developers when they start a new project.
  5. Flexibility for Development:

    • During development, having the application on a non-standard port like 8080 allows developers to run multiple applications on the same machine without having to configure a reverse proxy or modify existing server configurations.

Changing the Default Port

If you ever need to change the default port from 8080 to another port (including port 80), you can easily do so by modifying the application.properties or application.yml file in your Spring Boot project:

This change will configure your Spring Boot application to listen on the specified port.