Similar problem with #38937 , when i set management.server.port=${server.port} and in k8s env, it start failed and report "port in used", and when i set it to management.server.port=8081, it start successfully. And even when i set to "management.server.port=8080", it still start successfully. What's the special of "management.server.port=${server.port}"?

PS: When i start my app locally, it's all ok. And in k8s env, i must set management.server.port to different port.

Comment From: wilkinsona

Thanks for the report. Unfortunately, it doesn't include enough information for us to be able to diagnose the problem. Given that it works locally, it sounds like an issue in your K8S environment and that is out of Spring Boot's control.

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: xiangtianyu

Thanks for the report. Unfortunately, it doesn't include enough information for us to be able to diagnose the problem. Given that it works locally, it sounds like an issue in your K8S environment and that is out of Spring Boot's control.

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Since it appears in k8s env, i cannot reproduce it locally. Would you give me some suggestion about it to help me find the problem?

Comment From: wilkinsona

It's hard for me to make any suggestions as we know so little about the problem. We don't even know exactly what's failing to start due to the port clash. Is it the management server or the main server?

I would check the K8S deployment for anything that's not the same as when you run things locally. I'd look at environment variables, use of config trees, and so on. You could also try running locally the container that's being used when deploying to K8S. The should eliminate some possible differences and may also give you an opportunity to debug the application.

I'm going to close this one now as there's no evidence of a problem with Spring Boot. If the above does not help and you need further help in diagnosing the problem that's appears to be specific to your K8S environment, someone on Stack Overflow may have some further suggestions.