ESN Docs

Docs › Discord bots

How to keep a Discord bot online 24/7

Why your Discord bot goes offline when you close your PC, how hosting keeps it running 24/7, and the code habits that stop crashes and restarts.

A bot is just a program. When it runs on your computer, it goes offline the moment your PC sleeps, restarts or loses internet. To keep it online all the time, it has to run on a server that never turns off.

Run it on a host

  1. Pick a bot plan. Small bots are fine on Nano ($0.50/month) or Starter; you can also start with the free trial.
  2. Upload your bot: see the Python or Node.js guide, or other languages.
  3. Press Start. The bot keeps running after you close the panel or turn off your computer.

Habits that keep it up

  • Put the token in a variable, not in your code, so you never leak it in a screenshot or repo. If a token leaks, reset it in the Discord Developer Portal right away.
  • Catch errors in commands. One unhandled error in an event can stop the whole bot. Log the error and keep going.
  • Don't run two copies. Stop the copy on your PC once it runs on ESN, or both will answer every command.
  • List your packages in requirements.txt or package.json so they install on every start.
  • Restart on a schedule if memory slowly grows. See Schedules.

Still going offline?

Open the Console: the last lines before it stopped usually say why. Common causes and fixes are in Troubleshooting, and you can check whether a node is down on the status page.

Still stuck? Use the live chat on the panel or ask in the ESN Hosting Discord. Last updated October 27, 2026.