# Deploying Flask on Render? Read This Before You Start

> Learn how to deploy a Flask app on Render step by step, from Gunicorn setup to environment variables, and exactly what breaks on the Render free tier.
- **Author**: tyler-brooks
- **Published**: 2026-05-26
- **Modified**: 2026-05-26
- **Category**: Deployment Guides
- **URL**: https://kuberns.com/blogs/deploy-flask-on-render/

---

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](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/flask-render-prerequisites.png)

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://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/flask-render-steps.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
```

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
```

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:

| Setting | Value |
|---|---|
| Build Command | `pip install -r requirements.txt` |
| Start Command | `gunicorn app:app` |
| Instance Type | Free (for testing) or Starter ($7/month for production) |

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:

```python
import os
from flask_sqlalchemy import SQLAlchemy

app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
db = SQLAlchemy(app)
```

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](https://kuberns.com/blogs/deploy-python-app-on-render/)" covers the same setup pattern across Flask, Django, and FastAPI.

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/deploy-on-kuberns-bannner6.png" alt="Deploy Flask with Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## The Real Problems With Flask on Render

![The real problems with Flask on Render](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/flask-render-problems.png)

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](https://kuberns.com/blogs/render-pricing/)" 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](https://kuberns.com/blogs/add-custom-domain-to-your-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](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/kuberns-home-page-new.png)

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](https://dashboard.kuberns.com) 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](https://kuberns.com/blogs/what-does-one-click-deployment-do/)", 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](https://dashboard.kuberns.com/)

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/CTA_banner.png" alt="Deploy on Kuberns" style={{ width: "100%", height: "auto", cursor: "pointer" }} />
</a>

## Frequently Asked Questions

### Can I deploy Flask on Render for free?

Yes. Render's free tier supports Flask web services. Connect your GitHub repo, set the build command to `pip install -r requirements.txt` and the start command to `gunicorn app:app`, and your app goes live on an onrender.com subdomain. The free tier spins down after 15 minutes of inactivity, causing around 60 seconds of delay on the next request.

### Does Flask work on Render without Docker?

Yes. Render supports Flask without a Dockerfile. You select Python 3 as the language, set your build and start commands, and Render handles the rest. You only need a `requirements.txt` file with Gunicorn listed as a dependency.

### Why does Render need Gunicorn for Flask?

Flask's built-in development server is not designed for production. It handles one request at a time and is not stable under real traffic. Gunicorn is a production-grade WSGI server that runs multiple worker processes, handles concurrent requests, and integrates cleanly with platforms like Render.

### How do I set environment variables for Flask on Render?

In the Render dashboard, open your web service, go to Environment, and add key-value pairs. Common variables include `SECRET_KEY` and `DATABASE_URL`. These are injected at runtime and accessible via `os.environ` in your Flask app.

### Why does my Flask app on Render take so long to load?

This is Render's free tier spin-down behaviour. Free web services go to sleep after 15 minutes of inactivity. The next request wakes the service, which takes about 60 seconds. Upgrading to a paid instance type eliminates this. Platforms like Kuberns keep your app always-on without a paid plan upgrade.

### Can I use a database with Flask on Render?

Yes. Render provides a managed Postgres database. Create a Render Postgres instance, copy the internal connection string, and add it as a `DATABASE_URL` environment variable in your Flask service. Connect in your app using SQLAlchemy with `SQLALCHEMY_DATABASE_URI` set to that value. Note that free Render Postgres databases expire after 30 days.

### What happens to uploaded files on Render's free tier?

Render uses an ephemeral filesystem. Any files written to disk during runtime are lost when the service redeploys, restarts, or spins down. If your Flask app handles file uploads, store them in an external service like AWS S3 or Cloudflare R2. Persistent disks are only available on paid Render plans.

### Is there a faster way to deploy Flask without configuring Gunicorn and Render manually?

Yes. Kuberns is an agentic AI deployment platform that reads your GitHub repo, detects that you are running Flask, and deploys your app automatically without any Gunicorn configuration, Dockerfile, or dashboard setup. Your app is live on a production URL with HTTPS and no cold starts.

---
- [More Deployment Guides articles](https://kuberns.com/blogs/category/deployment-guides/1/)
- [All articles](https://kuberns.com/blogs/)