70.2 Change the HTTP port
In a standalone application the main HTTP port defaults to 8080
, but can be set with server.port
(e.g. in application.properties
or as a System property). Thanks to relaxed binding of Environment
values you can also use SERVER_PORT
(e.g. as an OS environment variable).
To switch off the HTTP endpoints completely, but still create a WebApplicationContext
, use server.port=-1
(this is sometimes useful for testing).
For more details look at Section 27.3.4, “Customizing embedded servlet containers” in the ‘Spring Boot features’ section, or the ServerProperties
source code.