February 14, 2024August 19, 2024 Spring boot change default port of server By default, Spring boot applications start with embedded tomcat server start on default port 8080. We can change default server port to any other port, using any one of below technique. 1. Update default spring boot server port from application properties file We can do parcels of brilliant things by basically making few passages in application properties record in any spring boot application. Changing server port is one of them. 1.1. application.properties server.port=8081 1.1. application.yml server: port : 8081 2. Update the spring boot server port number programmatically EmbeddedServletContainerCustomizer interface is used to customize inbuilt tomcat configuration. 2.1. Spring boot2 – WebServerFactoryCustomizer interface Alter default application server port in spring boot2 applications by implementing ConfigurableWebServerFactory interface. @Component public class AppContainerCustomizer implements WebServerFactoryCustomizer< ConfigurableWebServerFactory > { @Override public void customize(ConfigurableWebServerFactory factory) { factory.setPort(8081); } } 2.2. Spring boot 1.x – EmbeddedServletContainerCustomizer interface Alter default server port in spring boot 1.x applications by implementing EmbeddedServletContainerCustomizer interface. @Component public class AppContainerCustomizer implements EmbeddedServletContainerCustomizer { @Override public void customize(ConfigurableEmbeddedServletContainer container) { container.setPort(8081); } } 3. Update Spring boot default port number from command line We will pass ‘server.port’ argument during application run command. java -jar -Dserver.port=8081 spring-boot-demo.jar Spring Boot application.properties spring boot portchange spring boot portchanging spring boot portdefault spring boot porthow can you specify the port on which a spring boot application runs?how to change default port in spring boothow to change port in spring boothow to change port number in spring boothow to change spring boot porthow to change the port in spring boothow to change the port number in spring boothow to change tomcat port in spring boot intellijhow to check which port spring boot is runninghow to configure spring boot application to listen on another porthow to define port in spring boothow to run spring boot application to custom porthow to set port in spring boothow to stop port 8080 in spring bootspring boot portspring boot port 80 address already in use share with other sitespring boot port 8080 already in usespring boot port changespring boot port configspring boot port configurationspring boot port environment variablespring boot port in application propertiesspring boot port in application yamlspring boot port in application ymlspring boot port number configurationspring boot port propertywhat is the command to run spring boot application to custom port