Please consider the following configuration to expose management endpoints over a different address than the public endpoints while using the same port for both servers:

management.server.address=127.0.0.1
management.server.port=8080

server.address=127.0.0.2
server.port=8080

(The addresses are just an example)

This results in the following exception while starting up the application:

java.lang.IllegalStateException: Management-specific server address cannot be configured as the management server is not listening on a separate port
    at org.springframework.util.Assert.state(Assert.java:76)
    at org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration$SameManagementContextConfiguration.verifyAddressConfiguration(ManagementContextAutoConfiguration.java:90)
    at org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration$SameManagementContextConfiguration.afterSingletonsInstantiated(ManagementContextAutoConfiguration.java:76)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:963)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:923)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:326)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:144)

I believe something similar was already discussed on #22142 (and #22187) but in that issue the cause was not defining the management.server.port property explicitly. In this case we are defining the port and address properties for both servers and, since each server has its own address, it should't be a problem if they "share" the same port.

Could you consider supporting this use case?

[Tested with Spring Boot v 2.4.3.]

Comment From: wilkinsona

Yeah, I think that's something we should consider. The hardest part may be testing it as we'd need an environment with two different addresses and we'd also need to bind to a fixed port that's free on both addresses.