SoFunction
Updated on 2025-03-02

Check out several ways to start SpringBoot's local port number

To view the port number of a locally launched Spring Boot application, you can determine it in the following ways:

1. View or configuration file

If you configure the port number in a Spring Boot project, it is usually configured in src/main/resources/ or files. You can view the following configuration:

:

=8080

:

server:
  port: 8080

If not specified, Spring Boot will use port 8080 by default.

2. View console output

When you start the Spring Boot application, the console outputs startup information, which contains the application's port number. For example:

Tomcat started on port(s): 8080 (http) with context path ''

You can find similar information in the console's output to confirm the port number the application is listening on.

3. Use Actuator endpoints

If you have enabled Spring Boot Actuator in your project, you can get runtime information through the Actuator endpoint. Make sure that Actuator is configured in or:

=*

Then, visit the following URL to view the health status and other information of the app (assuming your app is running on the default port 8080):

http://localhost:8080/actuator/health

4. Configure through code

If you set the port number dynamically in the code, you can find the relevant code in the main method. For example:

@SpringBootApplication
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication app = new SpringApplication();
        ("port=8081"); // Dynamic ports may be set here        (args);
    }
}

5. Check project dependencies

If you use a specific HTTP server (such as Tomcat, Jetty, etc.), you can check the relevant configuration classes to confirm port settings.

Summarize

Typically, you can easily find the port number of your Spring Boot application by viewing , file or console output.

This is the article about several ways to view the local port number of SpringBoot locally. For more information about viewing the port number of SpringBoot, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!