Welcome to the Linux Foundation Forum!

"Instrumentation of the Python (Flask) Component (1)" - port 5000 issue

I'm using the devcontainer for the course. Unfortunately port 5000 is used on Mac OS X by the Airplay receiver service. You'll get an http 403 from it when connecting to localhost:5000. It may not be obvious to many students that this response is coming from the Airplay receiver and not the flask port.

As a workaround, I used the already port-forwarded 5001:

flask run -p 5001

instead of:

python app.py

Similarly, in the part where we use auto-instrumentation:

opentelemetry-instrument flask run -p 5001

instead of:

opentelemetry-instrument python app.py

Not a flask aficionado myself; perhaps there is a more idiomatic way to handle this.

Comments

  • fazlur.khan
    fazlur.khan Posts: 64

    Hello @mhite

    When you start a Flask application without specifying a port explicitly, Flask runs on localhost:5000 by default.

    Explicitly specify a different port (e.g., port 5001) as you've done is a good workaround.

    Another possible workaround (less recommended but sometimes useful): from System Setting, Turn off airplay to free up the port 5000.

    Alternatively, by using environment variables you can set the Flask application's default port

    export FLASK_APP=app.py
    export FLASK_RUN_PORT=5001

    -Thanks,
    Fazlur

Categories

Upcoming Training