Use the Flask development server for coding, and use Gunicorn for real users. That is the simple answer. When you see Running on http://127.0.0.1:5000, Flask is saying, “Hey, your app is alive on your own machine.” It is not saying, “Please invite the whole internet over.” The Flask docs say the built-in server is for local development and should not be used in production [source: Flask].
TLDR: http://127.0.0.1:5000 means your Flask app is running locally, usually with Flask’s built-in development server. That is great for testing routes, fixing bugs, and checking pages in your browser. If 1 developer is testing 20 requests per minute, Flask’s server is fine; if 500 users hit the app at lunch time, use Gunicorn. Example: use Flask while building a pizza ordering app, then run it with Gunicorn before real hungry people show up.
What does http://127.0.0.1:5000 mean?
127.0.0.1 is your own computer. It is also called localhost. Think of it as your laptop looking in the mirror.
5000 is the port. A port is like a tiny door. Flask often uses door number 5000 by default. So when your terminal says:
Running on http://127.0.0.1:5000
It means your Python web app is running on your machine. Open that address in your browser. Boom. Your app appears.
The Flask development server is your workshop
The Flask development server is built for comfort. It is friendly. It starts fast. It reloads when you change files. That feels magical when you are fixing a typo for the ninth time.
You usually start it like this:
flask run
Or sometimes:
python app.py
Then Flask gives you the local address. You click it. You test your app. Life is good.
Use it when you are:
- Writing new routes.
- Testing templates.
- Checking forms.
- Debugging errors.
- Trying an idea at 1:13 a.m.
The nicest part is the debug mode. If your app crashes, Flask can show you the error page. It can point at the broken line. That saves time. It also saves your forehead from the desk.
But debug mode is also why you should not expose it to strangers. It can reveal details about your app. That is useful for you. It is way too useful for attackers.
Gunicorn is the serious server buddy
Gunicorn means “Green Unicorn.” Yes, really. It is a Python WSGI HTTP server. That sounds fancy. The idea is simple.
Gunicorn sits in front of your Flask app and handles web requests in a stronger way. It can run multiple worker processes. Each worker can deal with requests. If one worker gets busy, another can help.
You might run it like this:
gunicorn app:app
Here, the first app is often the file name. The second app is the Flask object inside that file.
A more production-like command may look like this:
gunicorn --workers 4 --bind 0.0.0.0:8000 app:app
That starts 4 workers and binds the app to port 8000. Gunicorn recommends a basic worker count formula of 2 x CPU cores + 1 [source: Gunicorn]. So a 2-core server may start with 5 workers. Then you test. Do not guess forever. Measure.
Flask server vs Gunicorn, in plain English
Here is the clean split.
- Flask development server: for building the app.
- Gunicorn: for running the app for users.
The Flask server is like cooking in your home kitchen. You can taste the sauce. You can make a mess. You can restart the stove if needed.
Gunicorn is like a restaurant kitchen. It needs to serve many people. It needs order. It should not fall apart because two tables ordered soup at the same time.
Why not just use Flask’s server forever?
Honestly, it feels like it should work. You run Flask. The page loads. Your friend opens it. Maybe it still works. So what is the big deal?
The big deal is traffic, safety, and stability.
The development server is not built for heavy use. It is not tuned for slow clients. It is not meant to sit online all day. It may behave fine during a demo with 3 people. Then it may act weird when 80 people refresh at once because someone posted your link in Slack.
It drives me crazy that this failure can look random. One request works. The next hangs. A form submit takes 6 seconds instead of 200 milliseconds. Then you start blaming your database. Poor database. It was innocent.
Common pain points with the Flask development server in public:
- Weak request handling under load.
- Debug output that may expose private details.
- No smart worker management.
- Less control over timeouts.
- Bad fit for long-running public apps.
Where does Nginx fit?
You may hear people say, “Use Nginx with Gunicorn.” That is common.
Gunicorn runs your Python app. Nginx can sit in front of it. Nginx can handle HTTPS, static files, buffering, and client connections. Then it passes app requests to Gunicorn.
A common setup looks like this:
- Browser asks for a page.
- Nginx receives the request.
- Gunicorn talks to Flask.
- Flask creates the response.
- Nginx sends it back.
That may sound like a lot. But each part has a job. That is the point.
What about 127.0.0.1 versus 0.0.0.0?
This part trips people up.
127.0.0.1 means “only this machine.” If Flask runs on 127.0.0.1, other computers usually cannot reach it.
0.0.0.0 means “listen on all network interfaces.” That can allow other machines to connect, if firewalls and network rules allow it.
For example:
flask run --host=0.0.0.0
This can be useful for testing from your phone or another laptop. Still, do not confuse “reachable” with “production ready.” A cardboard door is still a door. It is just not a very good one.
A simple rule for beginners
Use this rule and you will avoid many weird nights.
- Building locally? Use Flask’s development server.
- Showing a private demo? Flask is okay, but be careful.
- Running for real users? Use Gunicorn.
- Serving a public site? Use Gunicorn behind Nginx or a platform that handles that layer.
A tiny example project
Imagine you build a small app called SnackVote. Your team votes on Friday snacks. Chips win too often. People complain. Democracy is messy.
During coding, you run:
flask run
You visit:
http://127.0.0.1:5000
You add buttons. You fix the “pretzels” typo. You break login. You fix login. The Flask server is perfect here.
Then the whole company wants to vote. There are 300 people. Now you run the app with Gunicorn on a server. Maybe you use 4 workers. Maybe you put Nginx in front. Now SnackVote has a fighting chance.
Final takeaway
http://127.0.0.1:5000 is your local playground. Treat it that way. Flask’s development server is fun, fast, and helpful while you code. Gunicorn is the better choice when real users arrive, real traffic appears, and your app needs to stop acting like a science fair volcano.