Sites and apps
Free hosting for a Python website: Flask, Django, FastAPI
In short
A Flask, Django or FastAPI website can be hosted for free on Netrun: upload the folder with your code and requirements.txt as an archive or from GitHub, and the platform installs the dependencies, starts the app and gives you an HTTPS link. One website on the free plan runs with no time limit and without a bank card. The app should listen on 0.0.0.0 and the port from the PORT environment variable, and when nobody visits, the site sleeps and wakes up by itself on the first visit.
- Netrun runs Flask, Django and FastAPI websites for free with no time limit.
- To run a Python website you only need the code folder and a requirements.txt file — no server or nginx setup.
- A Python website has to listen on 0.0.0.0 and the port from the PORT environment variable.
- Data the site writes to the /data folder is kept across code updates and sleep.
- On the free plan the site sleeps when nobody visits; it runs without sleeping on the Pro plan.
A Python website is harder than a page of HTML: you cannot just put its files on a host, it has to be started. That is why most free website hosts do not fit Python at all, and those that do give you a one-month trial, ask for a foreign bank card or expect you to set up gunicorn, nginx and a certificate yourself.
Below is how to put a Flask, Django or FastAPI website online for free and for the long run: what to fix in the code before uploading, how to publish and what the limits of the free plan are.
| What to check | Why it matters | On Netrun |
|---|---|---|
| Time limit | Many free plans are a one-month trial | No time limit, the site is not switched off |
| Card | Foreign platforms ask for a card to verify you | Not needed |
| Server setup | gunicorn, nginx and a certificate are usually set up by hand | The platform does it |
| HTTPS | Without it the browser scares visitors with a warning | Right away, renewed automatically |
| Data | SQLite inside a container is lost on update | The /data folder survives updates |
| Sleep | The first response after a pause is slower | Wakes in a couple of seconds, never sleeps on Pro |
List your dependencies in requirements.txt#
The platform installs exactly what is listed in requirements.txt. Make sure it contains the framework itself — flask, django or fastapi — and everything you import in the code. The quickest way to build the list is pip freeze inside the project virtual environment. A forgotten library is the most common reason a site crashes on its first start.
Listen on 0.0.0.0 and the port from PORT#
The built-in Flask and Django servers listen on 127.0.0.1 by default, which is not reachable from outside. Set the host to 0.0.0.0 and take the port from the PORT environment variable: in Flask that is app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 8080))), in FastAPI the same host and port when you start uvicorn. For Django, add the site address to ALLOWED_HOSTS or allow every address with an asterisk.
Decide where to keep data#
If the site writes to an SQLite database or saves uploaded files, keep them in the /data folder: whatever is there survives code updates and sleep. Files next to the code are replaced by the new version on the next publish. For a site with no data of its own you can skip this step.
Upload the project to Netrun#
Pack the code folder into a ZIP archive without venv and __pycache__, or connect a GitHub repository. Netrun sees that it is Python, detects the framework, installs the dependencies and starts the app. If the code reads secrets — an email key, a password for an external database — the platform asks for them before publishing and passes them in as environment variables.
Open the link and check the logs#
When the build is done, the site opens on an HTTPS link. If you see an error instead of the page, open the logs tab: it shows what the app printed on start — a wrong address, a missing library or a bug in the code. Fix it and upload a new version; the link stays the same.
Free hosting for a Python website does not have to be a one-month trial with server setup. On Netrun one Flask, Django or FastAPI website runs for free with no time limit. If the site ever needs a custom domain or responses without a wake-up pause, moving to Pro changes nothing in the code.
Common questions
Can I host a Django website for free?
Yes. Netrun runs Django websites on the free plan with no time limit. You need requirements.txt, the 0.0.0.0 address, the port from the PORT variable and the site address in ALLOWED_HOSTS.
How long will a free Flask website keep running?
With no time limit. The Netrun free plan is not a trial: the site is not switched off after a month. When nobody visits, it sleeps and wakes up by itself on the first visit.
Do I need to set up gunicorn and nginx?
No. The platform starts the app, receives visitors and issues the HTTPS certificate. If you want to run the site through gunicorn or uvicorn, put that in your own Dockerfile, but a regular site does not need one.
Will an SQLite database be kept?
Yes, if the database file lives in the /data folder: it survives both code updates and sleep. A database next to the code is replaced on every publish.
Can I publish a Python website with a PostgreSQL database?
Yes. You can connect an external database with a connection string from your secrets or run one next to the site in docker-compose. For a small site, SQLite in the /data folder is often enough.
Is this free hosting?
For websites — yes, with no time limit: it is not a trial, and a free website is not switched off after a month. No card is needed, there are no ads on the site, and the link opens over HTTPS right away. The site sleeps when nobody visits and wakes up by itself in a couple of seconds when someone opens it. A bot or a background script can be started and tried for free for 3 hours — they are busy all the time and cannot sleep, so after that they need the Pro plan. If you need several projects, you can add places to the Pro plan — each place gives you one more project. You can also get Pro for free by inviting friends: a week of Pro for every friend who publishes a project, up to four weeks a month.
Can I run a Python project — Django, Flask or FastAPI?
Yes. Put your dependencies in requirements.txt — Netrun detects Python and builds the project for you. Django, Flask and FastAPI are supported; the app should listen on the port from the environment variable, and keys and database access are set as secrets rather than in the code.