/replit-tutorials

How to deploy a Flask app on Replit

Learn how to easily deploy a Flask app on Replit with step-by-step setup, hosting tips, and simple instructions for beginners.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to deploy a Flask app on Replit

To deploy a Flask app on Replit, you create a new Python Repl, add a simple Flask app in main.py, make sure your app listens on host="0.0.0.0", add Flask to requirements.txt, and then use Replit’s built‑in Run button or the Deploy panel to ship it. Replit will automatically expose your web server on a public URL as long as Flask is running on the correct host and port.

 

What you actually need to do (the reliable way)

 

This is the workflow most Replit developers use when standing up a real Flask app. Nothing fancy, no made-up features — just the pieces that actually work on Replit today.

  • Create a new Repl using the Python template. You do not need the “Flask” template — the plain Python one is more predictable and avoids old boilerplate.
  • Open main.py and write a minimal Flask server. Replit will detect it automatically as long as you run it.
  • Add dependencies in a requirements.txt file so Replit installs Flask when the Repl boots.
  • Make sure Flask runs on host="0.0.0.0". This is crucial because Replit forwards traffic from the public URL to your dev container using this network binding.
  • Click Run to test locally (in Replit’s dev environment). If your webserver boots properly, you will see a green “Webview” button or a URL appear.
  • Go to the left sidebar → Deployments → choose Autoscale or Static Deployment (for Flask you always want Autoscale). Deploy.

 

Minimal Flask setup that works on Replit

 

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello from Flask on Replit!"

if __name__ == "__main__":
    // Replit forwards the PORT environment variable; this is important!
    import os
    port = int(os.environ.get("PORT", 5000))
    app.run(host="0.0.0.0", port=port)

 

Add requirements.txt

 

Flask==3.0.0

 

Replit automatically installs dependencies from this file. Keeping versions pinned avoids breakage.

 

Understanding what’s actually happening on Replit

 

When you click Run, Replit starts whatever is in main.py or whichever file you’ve set as your Run command. Flask must bind to 0.0.0.0, not 127.0.0.1, because 127.0.0.1 only listens inside the container — meaning Replit’s web server can’t reach it. Replit provides a PORT environment variable so it knows what port to forward to; using anything else breaks deployment.

Once your server launches successfully, Replit exposes a preview URL. When you move to the Deployments panel and choose Autoscale, Replit packages your app, spins it up in their hosted environment, and gives you a stable public URL. Deployments run without keeping the editor open, unlike the old “Always On” feature.

 

Common pitfalls you should avoid

 

  • Forgetting requirements.txt — your deployment will fail because Flask isn’t installed.
  • Binding to 127.0.0.1 — Replit won’t route traffic and you’ll just see connection errors.
  • Blocking the main thread — Flask needs to keep running. Avoid long loops in the top level of your file.
  • Printing sensitive data — logs are public to anyone with Repl access. Put secrets into Replit’s Secrets tab, not in code.

 

A simple mental model for Flask on Replit

 

Think of your Repl as a small container that exposes exactly one web server. As long as Flask is running on the correct host and port, Replit handles the URL routing, HTTPS, logs, and deployment. You write normal Flask code — just remember the environment differences (the PORT variable, and no local files that you expect to persist across deployments).

This setup is stable, real-world tested, and safe for both small student apps and production toy projects.

Still stuck?
Copy this prompt into ChatGPT and get a clear, personalized explanation.

This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.

AI AI Prompt

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022