It runs, but it won’t stay online reliably
You can run a discord.js or discord.py bot in Termux on Android, and it works for testing. It won’t stay online reliably. Android limits background apps to save battery, the phone may switch networks, and the bot stops whenever the phone restarts, overheats or runs flat. An iPhone can’t keep a background process running at all. For 24/7 uptime, run the bot on a host and use your phone to control it.
What takes a phone-hosted bot offline
| What happens | Effect on the bot | Can you work around it? |
|---|---|---|
| Screen off, battery optimization | Android pauses or kills Termux | Partly: termux-wake-lock and a battery exemption, at the cost of battery |
| Wi-Fi to mobile data | The connection to Discord drops | The library reconnects, after a gap |
| Reboot, update or flat battery | The process is gone | Only by restarting it by hand |
| Heat while charging all day | The system throttles or closes apps | No, and it wears the battery |
| Webhook bots (Telegram) | Carrier networks rarely accept incoming connections | Use polling instead |
Keep the phone, move the process
Put the same code on a host and keep the phone as the remote control. On Bothosting, the free Spark plan runs one bot with 256 MB of memory and 25% CPU. It doesn’t sleep when idle. Turn on Restart on crash and it comes back after an error. The iOS app or the Android app alerts your phone when it stops unexpectedly, and lets you restart it, read live logs, edit files and change variables. If you already have the bot working in Termux, push the project to GitHub and connect that repository to the deployment. With the push webhook, each later commit redeploys it. See hosting a Discord bot from your phone.
When a phone is good enough
A phone is fine for trying a bot for an evening, testing a command or learning the library. Use a test application with its own token so a crash on the phone doesn’t affect your real bot. Before moving to a host, stop the copy on the phone. Two processes logged in with the same token both reply to each command. Testing a Discord bot before deploying.