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
you cannot run two http servers on the same thread.
I don't know why but the implementation of the prometheus\_client doesn't runs the server on a separate thread.
my solution is

```
import logging.config
import os

import connexion
from multiprocessing.pool import ThreadPool
from prometheus_client import start_http_server

app = connexion.App(__name__, specification_dir='./')
app.add_api('swagger.yml')

# If we're running in stand alone mode, run the application
if __name__ == '__main__':
    pool = ThreadPool(1)
    pool.apply_async(start_http_server, (8000, ))  # start prometheus in a different thread
    app.run(host='0.0.0.0', port=5000, debug=True) . # start my server

```