Your Flask API is live, and the Telegram bot that sends booking reminders runs right beside it. Everything works beautifully, until your laptop goes to sleep. Then the bot goes quiet, the reminders stop, and you discover that "running" and "hosted" are not the same thing.
Python is brilliant at web apps, APIs, automation, and bots, which is exactly why hosting it can be confusing. A Python project is rarely just one process.
This guide explains how to host a Python web app based on what you've actually built, what each type needs in production, and how to keep the always-on parts running 24/7.
New to app hosting in general? Our guide to web app hosting covers the basics first.
Key Takeaways: How to Host a Python Web App
- Start with what you built. A Python web app, an API, a worker, and a bot each need slightly different hosting.
- Web apps and APIs need a production web server, such as Gunicorn for Flask or Uvicorn for FastAPI.
- Workers, bots, and scripts need an always-on process. Hosting that sleeps or caps your hours will stop them.
- Free hosting suits experiments, but anything that must run 24/7 usually needs a paid plan.
- HCode runs Python web apps, workers, and bots side by side in South Africa, with PostgreSQL included, from R50 a month.
How to Host a Python Web App: Start With What You Built
The right way to host a Python web app depends on what kind of Python application it is. Most projects fall into one of four types, and plenty of real projects combine two or three.
| What you built | Example | What it needs to run |
|---|---|---|
| Web app | A Flask site with logins and a dashboard | A web server, a database, and secrets kept safe |
| API | A FastAPI service behind a mobile app or React frontend | An ASGI web server, a database, and often Redis |
| Worker | A Celery or RQ queue consumer sending emails | An always-on process and Redis |
| Bot or script | A Telegram bot, or a script that syncs data every hour | An always-on process that never sleeps |
Web apps answer visitors in a browser, so they need a public address and a web server in front of your code.
APIs answer other software, such as a mobile app or a JavaScript frontend. They look a lot like web apps from a hosting point of view, but often lean harder on speed and Redis.
Workers do the slow jobs in the background, like sending emails or processing uploads, so your web app can answer visitors quickly.
Bots and scripts don't wait for visitors at all. They run on their own, around the clock, which makes them the easiest to underestimate and the first to break on the wrong hosting.
Building with Django? It has a few extra production habits of its own, covered in our guide on how to host a Django website.

What Python Web Apps Need in Production
Whatever you've built, hosting Python in production comes down to four needs.
1. A production web server. Flask's and FastAPI's built-in servers are for development only. In production, web apps and APIs run behind a proper web server. Flask is a WSGI app, so it usually runs on Gunicorn. FastAPI is an ASGI app, so it usually runs on Uvicorn. Think of WSGI and ASGI as two different plug shapes: your hosting just needs the right socket.
2. Dependencies listed properly. Your host installs your packages from a file such as requirements.txt or pyproject.toml. If a package isn't listed, it won't be there in production, no matter how well it works on your laptop.
3. Secrets kept out of your code. API keys, bot tokens, and database passwords belong in environment variables, not in your repository. Anyone who can read your code shouldn't be able to read your keys.
4. A database with one connection string. Most Python web apps store data in PostgreSQL, connected through SQLAlchemy, psycopg, or an ORM. Your host should give you a connection string and keep the database backed up.
Workers and bots don't need a web server, but they share needs two to four. And they add one more: they have to keep running.
Bots, Workers, and Scripts That Need to Run 24/7
Python bot hosting and worker hosting have one requirement above all others: the process has to keep running, with no visitor needed to wake it up.
That sounds simple, but it rules out a lot of hosting. Free tiers often put apps to sleep when nobody visits, or cap the hours they can run each month. A Telegram or Discord bot that's asleep misses every message sent while it's out. A queue worker that stops leaves jobs piling up. And shared hosting usually ends long-running processes, because it's built for websites that answer a request and finish.
Scripts that should run on a schedule, like a data sync every hour or a report every morning, need the same thing. Instead of relying on cron, a common approach on managed platforms is to run the script as an always-on worker with the schedule built in, using a library such as APScheduler, or a simple loop that waits between runs.
A quick test for anything you want to run online 24/7: if it still has to work at 3 a.m. when nobody's visiting your site, it needs hosting that stays on.
Where to Host a Python Web App: Your Options
There are four common places to host Python web apps, and they differ mostly in how well they handle the always-on parts.
Free tiers are great for learning and quick demos. The catch is that most sleep when idle, cap your monthly hours, or limit commercial use, which makes them a poor fit for bots and workers.
Shared hosting is built mainly for PHP websites. Some plans offer a Python app option, but recent Python versions, background workers, and Redis are often off the table.
A VPS runs anything. You install Python, set up the web server, keep your workers alive with a process manager, and look after security and backups yourself.
A managed app platform detects your Python project, builds it, and runs it. The better ones run web apps, workers, and bots as separate always-on apps, with the database and Redis beside them.
| Need | Free tier | Shared hosting | VPS | Managed app platform |
|---|---|---|---|---|
| Production web server | Usually | Limited | You set it up | Handled for you |
| Always-on workers and bots | Rarely | Rarely | Yes, with a process manager | Yes |
| PostgreSQL | Often limited or temporary | Rarely | You install it | Often included |
| Redis | Rarely | Rarely | You install it | Often included |
| Who maintains it | The provider, within limits | The host, within limits | You | The platform |
Hosting Python Web Apps on HCode
HCode is HostAfrica's managed app platform, built to run every part of a Python project side by side, not just the web app. Getting started takes three steps:
- Pick a plan. Choose one on the Python hosting page and order it in the HostAfrica client panel. Plans start at R50 a month, and code HCODEFREE2026 makes your first month free.
- Connect your code. Link your GitHub repository or upload a .zip, then add your API keys, bot tokens, and other secrets as environment variables.
- Push. HCode detects Python, installs your dependencies, and starts your app over HTTPS. Every push after that ships a fresh release.
| What you built | On HCode |
|---|---|
| Flask, FastAPI, or Django web app | Detected and built from your repository, served with SSL |
| Worker | Runs as its own always-on app, with managed Redis for Celery or RQ |
| Bot or scheduled script | Runs as an always-on background worker, with no visitor needed to keep it awake |
| Database | Managed PostgreSQL beside your apps, connected with one connection string and backed up daily |
| Secrets | Stored encrypted in the panel, never in your repository |
| System packages | Bring your own Dockerfile if your app needs extra libraries |
| Releases | New releases go live without downtime; a failed build never replaces the live app, and rollbacks take one click |
Your web app, workers, and bots run together on a private network in South Africa, on one flat price in rand. And if you're moving an existing app, you can import your PostgreSQL data from a .sql file or pg_dump archive.
Prefer to Run It Yourself?
If you'd rather manage the server, Gunicorn or Uvicorn, and the process manager yourself, a VPS gives you full control. Our step-by-step guide shows you how to deploy a Python app from GitHub to a VPS, from the virtual environment through to keeping your app alive with systemd and putting Nginx in front of it.
FAQs: Hosting a Python Web App
Where Can I Host a Python Web App?
On any host that runs a recent Python version behind a production web server. For apps with workers, bots, or a database, a managed app platform or a VPS works best, because both can keep processes running around the clock.
Can I Host a Python Bot for Free 24/7?
Sometimes, but free hosting usually sleeps when idle or caps your monthly hours, so a bot can go quiet without warning. For a bot that must stay online, always-on hosting is the safer choice. HCode has no free tier, but code HCODEFREE2026 gives you your first month free.
Can I Run Flask or FastAPI on HCode?
Yes. HCode detects Python projects and builds them from your repository, whether you use Flask, FastAPI, or Django. Add a Dockerfile if your app needs a custom setup.
How Do I Run a Python Script 24/7?
Run it as an always-on worker instead of on your own computer. If the script should run on a schedule, build the schedule into the script, for example with APScheduler, so it waits and runs at the right times.
Is a Database Included?
Yes. Every HCode plan includes managed PostgreSQL, backed up daily, and you can add Redis for queues and caching.
What About Django?
Django runs on HCode too, and it has a few production settings of its own. Our guide on how to host a Django website covers them.
