Skip to content

Host a Discord bot

A Discord bot is a program that must stay connected to Discord: if it stops, the bot goes offline and stops answering. You can run it on your computer, on a rented VPS, or leave it to a service such as discbot.net. Each option has a cost, needs different skills and comes with its own limits.

Updated

Why does a bot need hosting?

Creating the application in the Developer Portal does not bring the bot to life. Discord waits for a program to connect with the token and stay connected. Until one does, the bot shows as offline, and its slash commands end with “The application did not respond”.

You type in discbot.net

Every Friday at 6 pm, remind people about game night in #announcements, with an “I’m in” button.

discbot.netDone. Reminder every Friday at 6 pm in #announcements.

announcements
Club BotAPP

Reminder: game night tonight at 9 pm. Tell us if you are coming!

I’m in
Example shown in English; you would ask in French for now. A scheduled reminder only goes out if the bot is connected at that moment. That is what hosting is about.

Which option should you pick?

Three ways to run a Discord bot
Your computerA VPSdiscbot.net
PriceFree, apart from electricityA monthly plan from a hosting companyFree for now, with approval during the private beta
Bot onlineOnly while the computer is on and connectedAll the time if the machine and bot are set up wellNo machine of yours; no 24-hour guarantee during the beta
Skills neededInstall Node.js, start the bot, restart itLinux, SSH, updates, automatic restartsNothing technical: describe, test, publish (in French for now)
What the bot can doAnything your code doesAnything your code doesWhat discbot.net allows: no music, files or other websites
The tokenOn your computer, your responsibilityOn your machine, your responsibilityIn an encrypted vault, never given to the bot’s code
How many botsAs many as your machine handlesAs many as your machine handlesOne bot per account, one server per bot

In short: your computer is enough to learn and test; a VPS suits you if you code yourself and want full control; discbot.net suits you if you do not want to code and its limits work for you. Some free hosting plans put programs to sleep after a while: check that before you install a bot there.

How do you host a bot yourself?

For a bot you wrote in JavaScript with discord.js, on your computer or a VPS:

  1. Install Node.js

    Get the LTS version from nodejs.org. On a VPS, use your distribution’s package manager or the official installer.

  2. Install the library

    In the bot’s folder, run npm install discord.js.

  3. Keep the token out of the code

    Put it in an environment variable or a .env file you never publish. A token left in a public repository must be regenerated at once.

  4. Start the bot

    node index.js, for instance. The bot is online as long as the command runs.

  5. On a VPS, make it independent

    A process manager such as pm2, or a systemd service, restarts the bot after an error or a reboot.

  6. Maintain it

    Update Node.js, discord.js and the system. Watch the logs: that is where you will see why the bot stopped.

Discord’s getting started guide also walks through a complete first bot.

How does hosting work on discbot.net?

You describe your bot, test it in the browser, then click Publish. discbot.net runs its code in an isolated environment, connected to Discord with your token, on the server you picked.

  • The stop button turns the bot off without erasing anything: its data, such as game points, is kept.
  • Publishing a new version keeps that data.
  • If the bot takes too many sensitive actions at once, it is paused as a safety measure and you confirm the restart on the Publish page.
  • If the discbot.net server stops answering, your code and the bot’s data are kept.

What does discbot.net not do yet?

  • Host a bot you coded elsewhere: discbot.net runs bots written with its assistant.
  • Play music or sound in a voice channel.
  • Send files, or call other websites and services from the bot’s code.
  • Publish the same bot on several servers.

Why does a bot go offline?

ProblemThe bot turns off when you close your computer.
FixThat is expected: it runs on your machine. To keep it online you need a machine that stays on, such as a VPS, or a hosting service.
ProblemOn the VPS, the bot stops after an error or a reboot.
FixIt was started by hand. Hand it to pm2 or a systemd service, which restarts it on its own.
ProblemThe bot stops with “Used disallowed intents”.
FixThe code asks for a privileged intent that is off. Turn it on in the portal (intents guide) or remove it from the code.
ProblemOn discbot.net, the bot is paused.
FixA safety check stopped it after too many sensitive actions in one minute. Read the reason on the Publish page, fix it if needed, then confirm the restart.

Frequently asked questions

Can I host a Discord bot for free?

Yes, on your own computer, as long as it stays on. discbot.net also hosts it for free for now, for approved private beta accounts, with no guarantee of 24-hour operation.

What VPS does a small bot need?

A bot for a server of friends needs few resources: a hosting company’s smallest plan is usually enough. Memory matters more than processing power.

Is my data lost if I stop the bot on discbot.net?

No. Stopping the bot or publishing a new version keeps its data. It is only erased if you ask for it.

Free for now. Create your discbot.net account: during the private beta, hosting opens as soon as your access is approved.