Skip to content

Running the Dev Server

During development you typically run:

  • flask runflask run

This starts Werkzeug’s development server.

Typical output

You’ll usually see:

  • the URL (like http://127.0.0.1:5000http://127.0.0.1:5000)
  • that it’s a development server

Host and port

  • Default host: 127.0.0.1127.0.0.1 (only accessible from your machine)
  • Default port: 50005000

You can change them:

flask run --host 0.0.0.0 --port 8000
flask run --host 0.0.0.0 --port 8000

When should you use 0.0.0.00.0.0.0?

Use it when you want access from another device on your network.

Be careful: exposing dev servers is not recommended on public networks.

What happens when you visit the page?

  1. Browser connects to the host/port
  2. Sends GET /GET /
  3. Dev server forwards to Flask app
  4. Flask finds a matching route and runs your view function
  5. Response is returned

If you get a 404, it usually means:

  • you didn’t define the route, or
  • your URL doesn’t match the route rule

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did