3 Ways to Change Default 8080 Port in Spring Boot

By default, all applications that you create using Spring Boot will run on Port 8080, if you want your application to run on some other port, you need to add server.port property in the application.properties file located in the resources folder.

1. Change default 8080 Port using configuration file

  1. Go to src > main > resources package in your project,
  2. If you have a application.properties file,


  3. If you have application.yml file,

       port: <custom_port_no>

  4. Save the file.
  5. Run your Spring Boot app and it should now run on the custom port you set.
Change Spring Boot Default 8080 Port Example

2. Change default 8080 Port using VM Argument in IDE

You can also change the default port using the VM Argument, add it to your IDE,

IntelliJ IDE
  • Go to Menu: Run,
  • Select Edit Configurations.
  • Now in VM options add -Dserver.port=<custom_port_number>

Visual Studo Code IDE:
  • Open launch.json file under .vscode directory
  • Add the below "vmArgs": "-Dserver.port=<custom_port_number>"
Add Custom Port VS Code Spring Boot App

Eclipse IDE
  • Right Click on your Project,
  • Select Run Configurations,
  • Add "-Dserver.port=<custom_port_number>" under VM Arguments

3. Change default 8080 Port while running the jar file:

When you are executing your jar file app, you can pass the option --server.port


% java -jar my/jar/path/my-boot-app.jar --server.port=8070

Have Questions? Post them here!