HostRight

Flask hosting

How to Run a Flask API with Database and Redis for Less Than $3/Month

Deploy a Flask API with Python, MariaDB, Redis caching, SSL, environment variables, Git, SSH, logs, cron jobs, and backups on affordable managed hosting.

Published 2026-07-30 · 6 min read

You do not need a VPS to run every Flask API. For a small JSON API, webhook receiver, admin service, or internal tool, managed Python hosting can provide the important pieces for less than the cost of a coffee: a WSGI runtime, a database, HTTPS, private application files, and a way to deploy updates.

With HostRight, the Starter plan begins at $2.99/month and includes one website, one database, SSL, email, SSH, backups, and the control-panel tools needed to run a small Flask service. The limits are shared-hosting limits, so this is a good fit for a small API rather than a high-throughput platform.

What the under-$3 setup includes

  • Python application hosting through HostRight Control Panel and Passenger
  • One MariaDB database for application data
  • HTTPS with a managed SSL certificate
  • SSH, Git, SFTP, and environment-variable configuration
  • Daily backups on eligible plans
  • Cron jobs for scheduled tasks
  • Optional Redis for cache and short-lived state

The database, storage, CPU, memory, and request volume still need to fit within your selected plan. Check the current checkout page for the exact plan limits and billing term.

Create the Flask project

Keep the project outside the public web directory:

apps/flask-api/
├── app.py
├── passenger_wsgi.py
├── requirements.txt
└── .env.example

Use a simple WSGI application:

from flask import Flask, jsonify

app = Flask(__name__)

@app.get("/health")
def health():
    return jsonify(status="ok")

Passenger imports the WSGI callable from the startup file:

from app import app as application

Do not use flask run as the production process. HostRight's Python application interface starts the WSGI application for you.

Configure the application in HostRight

Open Extra Features → Setup Python App → Create Application and set:

Setting Example
Application root apps/flask-api
Startup file passenger_wsgi.py
Entry point application
Application URL api.example.com

Create the application, then activate the virtual environment shown by the panel:

cd ~/apps/flask-api
source ~/virtualenvs/flask-api/bin/activate
python -m pip install -r requirements.txt

Keep secrets in HostRight environment variables rather than committing them to Git:

FLASK_ENV=production
DATABASE_URL=mysql://USER:PASSWORD@HOST/DATABASE
SECRET_KEY=replace-with-a-random-value

Add the MariaDB database

Open Account Manager → Databases, create a database and user, and grant the user only the permissions the Flask application needs. Use the exact database host, name, username, and password shown in HostRight's database details.

For SQLAlchemy, keep the connection string in an environment variable and load it from your application configuration. Run migrations before sending production traffic, then test inserts, reads, authentication, and error handling.

Deploy and test

Use Git for repeatable updates:

cd ~/apps/flask-api
git pull --ff-only origin main
python -m pip install -r requirements.txt

Restart the Python application from HostRight Control Panel, then test:

curl -i https://api.example.com/health

Enable the domain's SSL certificate before accepting credentials or private data. Review the application and web-server logs if the API returns a 500 response.

What this setup is good for

This low-cost Flask setup works well for:

  • Small REST APIs and JSON backends
  • Webhook receivers
  • Contact forms and internal tools
  • Lightweight admin dashboards
  • Scheduled data collectors

Choose a VPS or a platform designed for background workers when you need long-running queues, WebSockets, unrestricted processes, custom ports, containers, or consistently high request volume.

For the complete Python deployment model, see Host Python applications with HostRight Control Panel and Phusion Passenger. For database setup, see Create and manage a database.