NetrunHome

Bots

Free hosting for a Python Telegram bot (aiogram)

· 5 min read

Your Python bot is ready: commands respond, aiogram is running, everything works on your computer. But the moment you close your laptop, the bot goes silent — because it lives locally on your machine. For it to answer around the clock, you need a computer that never shuts down, and usually that means renting a VPS, installing Python on the server, setting up autostart through systemd, and watching that the process does not crash.

For a bot on aiogram or pyTelegramBotAPI you can skip all of that. Let us walk through how to prepare your bot and run it on Netrun, where it will work without your computer and without any manual server setup.

  1. Collect your dependencies in requirements.txt#

    Create a requirements.txt file in the root of your project and list the libraries in it — aiogram itself (or pyTelegramBotAPI) and everything your bot uses. You do not need to put the folder with installed libraries (venv) into the archive: the platform builds the environment from this list on its own.

  2. Move the bot token out of your code#

    The token that BotFather gave you should not sit right in the code, and definitely should not end up in a public repository — otherwise someone could steal your bot. Read the token from an environment variable. When you set up the project, Netrun asks for this value and injects it as a secret outside your code.

  3. Use long polling, not a webhook#

    For a simple bot the easiest approach is to stay in long polling mode — where the bot itself asks Telegram for new messages. That way you do not need to run a web server, configure a webhook, or open a port. aiogram and pyTelegramBotAPI work in this mode out of the box, and for hosting it is the most trouble-free option.

  4. Check the start command#

    Make sure the bot starts with a single command — for example, python bot.py — and does not need any manual steps after it launches. If your entry point has a different name, the platform will offer to specify the start command during setup.

  5. Upload the project to Netrun#

    Upload the code as a ZIP archive or import it from a GitHub repository — a private one works too. Netrun detects on its own that this is Python and recognizes the project as a bot. You do not need to pick a server, a Python version, or a way to start it manually.

  6. Start and check the bot#

    Once the build finishes, the bot starts and begins answering in Telegram. Logs are visible in your dashboard in real time, so if the bot does not respond, the reason will be clear. On the Free plan a bot runs for 24 hours and then shuts down. Your code, settings, and secrets stay in place, and you get a warning shortly before it stops. For the bot to run around the clock, with no time limit, you need the Pro plan.

A Python bot needs neither your always-on computer nor a rented VPS with systemd. Upload your code to Netrun, move the token into a secret — and the bot starts answering. On the Free plan you can launch a bot and try it out: it runs for 3 days and then shuts down, while your code and settings stay in place. For the bot to answer around the clock, switch to the Pro plan.

Common questions

Where can I host a Python Telegram bot for free?

You can launch a Python bot and try it out for free: on the Netrun Free plan it runs for 24 hours and then shuts down. Your code, settings, and secrets stay in place, and you get a warning shortly before it stops. For the bot to answer around the clock, with no time limit, you need the Pro plan — current prices are shown on the plans page in your dashboard. The time limit applies only to bots and background scripts: a website on the Free plan lives as long as you like, because it can be put to sleep after a quiet spell and woken up when someone opens its link. A bot has no public link — it reaches out to Telegram itself, not the other way around, so there is nothing to wake it with.

Does this work for aiogram and pyTelegramBotAPI?

Yes. Netrun detects that this is a Python project and starts the bot regardless of the library. The main things are to collect your dependencies in requirements.txt, move the token into an environment variable, and stay in long polling mode.

Do I need a webhook and a web server?

No, for a simple bot long polling mode is enough — the bot fetches messages from Telegram itself. You do not need to run a web server, configure a webhook, or open a port.

Will the bot keep working when my computer is off?

Yes. After you put it online the bot lives on Netrun servers, not on your computer, so it answers regardless of whether your laptop is on.

Is it safe to store the bot token?

Yes, if you move the token into an environment variable and set it as a secret during setup. Then the token is not in your code or repository, and in the Netrun database it is stored encrypted.

Get your own project online

Upload your code, answer a couple of questions and get a working link. There is a free plan

Try Netrun
All blog articles