VOOZH about

URL: https://www.geeksforgeeks.org/python/how-to-change-port-in-flask-app/

⇱ Change Port in Flask app - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Change Port in Flask app

Last Updated : 29 May, 2026

Flask runs on port 5000 by default, but the port can be changed by specifying a different port while running the application. This is useful when the default port is already in use or when multiple applications are running on the same system.

Port can be changed by passing the port parameter in the app.run() method:

app.run(port=8001)

It can also be combined with debug mode:

app.run(debug=True, port=8001)

Example: This example creates a Flask app and runs it on port 8001 instead of the default port.

Output: Application will run on http://127.0.0.1:8001/

👁 How to Change Port in Flask app
Port number is 8001
👁 Image
Flask app

Explanation:

  • Flask(__name__) creates the application instance
  • @app.route("/") defines the home route
  • app.run(debug=True, port=8001) runs the app in debug mode on port 8001
Comment