DEV Community

Cover image for Deploying Flask on Render? Read This Before You Start
Kuberns
Kuberns

Posted on • Originally published at kuberns.com

Deploying Flask on Render? Read This Before You Start

Yes, you can deploy a Flask app on Render. The process is straightforward: connect your GitHub repo, configure two commands, and your app is live on an onrender.com URL with HTTPS included.

That is the short answer. The longer answer involves Gunicorn configuration, free tier limitations that catch most developers off guard, and a few setup details that Render’s documentation skips over. This guide covers all of it so you are not debugging at 11pm wondering why your app stopped responding.

What You Need Before Deploying Flask on Render

What you need before deploying Flask on Render

Before you open the Render dashboard, make sure you have the following in place.

A working Flask app with a clear entry point. Render needs to know which file and which variable to run. If your app is in app.py and your Flask instance is called app, the start command will be gunicorn app:app. If your structure is different, adjust accordingly.

A requirements.txt file that includes all your dependencies. Render runs pip install -r requirements.txt to install them. If this file is missing or incomplete, the build fails.

Gunicorn listed in your requirements.txt. Flask’s built-in server is not production-grade and Render will not use it. Gunicorn is required.

A GitHub repository with your code pushed to the main branch. Render connects to GitHub directly and deploys from there.

A free Render account. No credit card required to start.

How to Deploy Flask on Render Step by Step

![How to deploy Flask on Render step by step(https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5511a8gc555upvy60m6x.png)

Setting Up requirements.txt and Gunicorn

This is the step most tutorials gloss over and it is where most deployments fail first.

Your requirements.txt needs to include gunicorn explicitly. A minimal file for a Flask app looks like this:

flask
gunicorn
Enter fullscreen mode Exit fullscreen mode

If you are using a database or other packages, list those as well. If you want to pin Python to a specific version, create a runtime.txt file in the root of your repo with the version on a single line:

python-3.11.0
Enter fullscreen mode Exit fullscreen mode

Render reads this file and uses that version during the build. Without it, Render uses its default Python version, which may differ from your local setup.

The start command Render needs is gunicorn app:app. The format is module_name:flask_instance_name. If your Flask app is defined in a file called server.py and the instance is called application, the command would be gunicorn server:application. Get this right before deploying or your service will start and immediately crash.

Connecting Your GitHub Repo on Render

Log in to Render and click New, then select Web Service. Connect your GitHub account if you have not already. Find your repository in the list and click Connect.

Render will ask you to configure the service. Set the language to Python 3. Render auto-detects this in many cases but setting it manually avoids surprises.

Build Command, Start Command, and Deploy

Set the following values:

Build Command, Start Command, and Deploy

Click Create Web Service. Render kicks off the first build, installs your dependencies, and starts your app. The first deploy usually takes 2 to 3 minutes.

When the build completes, your app is live at yourapp.onrender.com. HTTPS is included automatically.

Every push to your connected branch triggers a new deploy going forward. If a build fails, Render keeps the previous version running.

Adding Environment Variables

Your Flask app almost certainly needs environment variables: a secret key, an API key, a database URL. Do not put these in your code.

In the Render dashboard, open your web service and go to the Environment tab. Add each variable as a key-value pair. Common ones for Flask:

  • SECRET_KEY (used by Flask for session signing)
  • DATABASE_URL (your database connection string)
  • FLASK_ENV (set to production)

These are injected at runtime and available in your app via os.environ.get('SECRET_KEY').

Connecting a Database

Render provides a managed Postgres database. Create a new Postgres service from the Render dashboard. Once it is created, copy the Internal Database URL from its settings page.

Go back to your Flask web service, open the Environment tab, and add DATABASE_URL with that connection string as the value.

In your Flask app, connect using SQLAlchemy:

import os
from flask_sqlalchemy import SQLAlchemy

app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
db = SQLAlchemy(app)
Enter fullscreen mode Exit fullscreen mode

Note: Free Render Postgres databases expire after 30 days. For anything beyond testing, use a paid Postgres instance or an external database like Supabase or PlanetScale.

**_

If you are also deploying other Python frameworks, the “complete guide to deploying Python apps on Render” covers the same setup pattern across Flask, Django, and FastAPI.
_**

The Real Problems With Flask on Render

The real problems with Flask on Render

The deployment works. Your app is live. Here is what happens next that nobody warns you about.

Cold Starts on the Free Tier

Render’s free tier spins down any web service that receives no traffic for 15 minutes. The next request wakes it up. That wake-up takes approximately 60 seconds, during which Render shows a loading page to your visitors.

For a personal project or internal tool, this is manageable. For anything with real users, it is a problem. A 60-second load time on first visit kills conversions and makes your app feel broken.

The only fix on Render is upgrading to a paid instance. The Starter plan at $7 per month keeps your service always-on. The “full Render pricing breakdown” covers what each tier actually includes.

750 Free Instance Hours Per Month

Render grants 750 free instance hours per workspace per month. A single always-running free service uses all of them. If you have multiple free services, they share this pool. When the hours run out, all your free services are suspended until the next month.

Ephemeral Filesystem

Any files your Flask app writes to disk during runtime are lost when the service restarts, redeploys, or spins down. This includes uploaded images, local SQLite databases, and any cached files written at runtime.

If your app handles file uploads, you need external storage. AWS S3 and Cloudflare R2 are the common choices. Persistent disks are available on Render but only on paid plans.

Custom Domain AAAA Record Warning

If you add a custom domain to your Flask app on Render, Render will warn you to remove any AAAA records pointing to IPv6 addresses. Render’s infrastructure is IPv4 only. Leaving AAAA records in place causes intermittent routing failures that are hard to debug because they only affect users on IPv6 networks.

**_

This is not a Flask-specific issue but it catches developers who copy DNS settings from another platform without checking. The “guide to adding a custom domain to any deployed app” walks through the correct DNS setup for Render and other platforms.
_**

Deploy Flask With One-Click Agentic AI on Kuberns

Deploy Flask with one-click agentic AI on Kuberns

Everything above works. But there is a faster path, and it removes every manual step you just went through.

Kuberns is an agentic AI deployment platform. You connect your GitHub repo, and the AI agent reads your code, detects that you are running Flask, configures the build pipeline, sets up the production environment, and deploys your app automatically. No Gunicorn configuration. No start command to figure out. No runtime.txt. No dashboard settings to get right.

Here is exactly how it works.

Step 1: Connect Your GitHub Repo

Sign in to Kuberns and click New Project. Connect your GitHub account and select your Flask repository. That is the only thing you configure manually.

Step 2: The AI Agent Reads Your Project

Kuberns scans your repo automatically. It detects the Flask framework, identifies your entry point, reads your requirements.txt, and determines the correct WSGI configuration. You do not tell it anything. It figures it out.

For Flask specifically, the agent sets up Gunicorn internally, pins the correct Python version, and configures the production environment without you writing a single config line.

Step 3: Set Your Environment Variables

Add your environment variables in the Kuberns dashboard under the Environment tab. Same keys as before: SECRET_KEY, DATABASE_URL, FLASK_ENV. Kuberns injects them at runtime exactly like Render does, but the interface is cleaner and the variables persist across every deployment without manual re-entry.

Step 4: Deploy

Click Deploy. Kuberns builds your app, provisions the runtime, sets up HTTPS, and makes your Flask app live on a production URL. The first deploy takes under two minutes. Every subsequent push to your connected branch deploys automatically.

What You Get That Render Does Not Give You

The difference is not just in setup time. It is in what happens after you deploy.

On Render’s free tier, your Flask app sleeps after 15 minutes of inactivity and takes 60 seconds to wake up. On Kuberns, your app is always-on. No cold starts. No loading screens for your users. No spin-down behaviour to work around.

On Render, you manage Gunicorn, Python versions, start commands, and WSGI configuration yourself. On Kuberns, the agentic AI handles all of that. You push code. Your app goes live. That is the entire workflow.

If you want to understand “how one-click agentic deployment works under the hood”, the breakdown covers what the AI agent does between your GitHub push and your app going live in production.

Deploy Your Flask App on Kuberns in One Click

Top comments (0)