Question: I'm running a web app with address 127.0.0.1:5000 and am using the python client library for Prometheus. I use `start_http_server(8000)` from the example in their [docs](https://github.com/prometheus/client_python) to expose the metrics on that port. The application runs, but I get `[Errno 48] Address already in use` and the localhost:8000 doesn't connect to anything when I try hitting it.

If I can't start two servers from one web app, then what port should I pass into `start_http_server()` in order to expose the metrics?

There is nothing already running on either port before I start the app.

Answer: 
When flask's `debug` mode is set to `True`, the code reloads after the flask server is up, and a bind to the prometheus server is been called a second time

Set flask app `debug` argument to `False` to solve it
Port 8000 does not need to have a web server running on it for it to be already in use. Use your OS command line to find the process that is using up the port then kill it. If a service is also running that causes it to get spawned again, disable that process.

A simpler solution would be to use another port instead of 8000.

**EDIT:** Looks like it is a bug in Prometheus. [Github Issue](https://github.com/prometheus/client_python/issues/155)