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
- Go to src > main > resources package in your project,
- If you have a application.properties file,
server.port=<custom_port_no>
- If you have application.yml file,
server:
port: <custom_port_no> - Save the file.
- Run your Spring Boot app and it should now run on the custom port you set.

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>"

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
Example:
% java -jar my/jar/path/my-boot-app.jar --server.port=8070
-
Have Questions? Post them here!
More Posts related to Java,
- Add two numbers using Java Generics
- Convert Java List to Json String using Jackson
- Convert Java Object to JSON using Jackson Library
- Java SE JDBC: Insert with PreparedStatement Example
- [Program] How to read three different values using Scanner in Java
- Java JDBC Batch Update Example with PreparedStatement
- Java Stream flatmap() Examples
- Save Java Object as JSON file using Jackson Library
- Java get day of the week as an int using DayOfWeek
- Create Nested Directories using Java Code
- Java JDBC Delete a Record in Database Table using PreparedStatement
- List of jars required for Struts2 project
- Convert Java Object to XML using Jackson Library
- Struts2 : java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
- Java JDBC Get Id of the Inserted Record with AutoIncrement
- How to list all tables using Java JDBC
- Java Jackson ObjectMapper Class with Examples
- Fix: Maven - Failed to execute goal - Compilation failure - Source/Target option 5 is no longer supported. Use 7 or later
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files
- Formatting Double in Java [Examples]
- How to run Java Unit Test cases with Apache Maven?
- [fix] NullPointerException Cannot Invoke findById because Repository is null - Java Spring
- [Fix] java: integer number too large compilation error
- [Java] Read a File with UTF-8 Encoding
- How to detect Operating System using Java code
More Posts:
- PHP Base64 encoding decoding a variable - PHP
- Plug-in com.android.ide.eclipse.adt was unable to lead class Error - Android
- [fix] Java NullPointerException ComparableTimSort countRunAndMakeAscending when sorting a List - Java
- Trace using cURL Command Example - cURL
- Replace delimiter with new line in Notepad++ - NotepadPlusPlus
- Calculate discount amount python code - Python
- The default interactive shell is now zsh. [macOS] - MacOS
- Take Screenshot on Mac OS X (Keyboard Shortcuts) - Mac-OS-X