DEV Community


Posted on

Why Do You Need Management Port in Your Dotnet Web App

Hello, in this short post I gonna explain why enterprise level apps should use management port.

What is management port

By default app uses only one port and exposes all information to clients via it. But what if we want some data to be private for clients? Let's say we want health check to be available for k8s but not for consumers of our API. How to do that? The answer is separation of concerns. You should use separate ports in your app for different purposes. It's secure and simple way to handle this.

Management port is a private port for service endpoints. It is often used for:

1) Health checks
2) Metrics
3) Custom endpoints for testing

Management port is usually not exposed outside so
you can be sure that clients won't access your private metrics or health checks data.

Configuring core provides set of environment variables for configuring ports. ASPNETCORE_MANAGEMENTPORT is responsible for management port, so your typical config looks like this:

"ASPNETCORE_URLS": "http://*:5000/;http://*:5001/",
Enter fullscreen mode Exit fullscreen mode

This config uses ports 5000 and 5001 in Kestrel, 5001 is management port.


Management port is fast and convenient way to expose private service endpoints in your app. Do you have those in your app? Feel free to answer in comments

Top comments (0)