Changing the Spring Boot Server Port Number

Changing the Server Port Number

You can specify the port number with server.port in the application.properties configuration file.

Change the configuration file as follows. application.properties

server.port=1598

Run the Application

$ gradle bootRun
(omitted)
2017-08-17 22:30:13.211  INFO 14485 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 1598 (http)
(omitted)

Description

  • For an explanation of application.properties, see here.
  • Other changes are also possible, such as the following.
    • server.address: Server address. If set to localhost, access is restricted to local access only.
    • server.sessionTimeout: Session timeout duration.