All About Cookies is an independent, advertising-supported website. Some of the offers that appear on this site are from third-party advertisers from which All About Cookies receives compensation. This compensation may impact how and where products appear on this site (including, for example, the order in which they appear).
All About Cookies does not include all financial or credit offers that might be available to consumers nor do we include all companies or all available products. Information is accurate as of the publishing date and has not been provided or endorsed by the advertiser.
The All About Cookies editorial team strives to provide accurate, in-depth information and reviews to help you, our reader, make online privacy decisions with confidence. Here's what you can expect from us:
- All About Cookies makes money when you click the links on our site to some of the products and offers that we mention. These partnerships do not influence our opinions or recommendations. Read more about how we make money.
- Partners are not able to review or request changes to our content except for compliance reasons.
- We aim to make sure everything on our site is up-to-date and accurate as of the publishing date, but we cannot guarantee we haven't missed something. It's your responsibility to double-check all information before making any decision. If you spot something that looks wrong, please let us know.
Discord bots can be remarkably useful. They can help you moderate your server, play music in your voice channels, or keep your community updated with news from other platforms. In fact, they can do almost anything you can imagine.
So, just how difficult is Discord bot hosting? It’s not overly complicated, but if you’ve never run a server or worked with Linux, then you will have some things to learn. In this guide, we’ll provide you with a solid introduction on how to add a Discord bot to your server, how to host it on a VPS server, and the key concepts required to do it yourself. Let’s get into it!
How to host a Discord bot on a VPS server
How to choose the best Discord bot hosting
Can you host a Discord bot for free?
FAQs
Bottom line
How to make a Discord bot
First, you will need the code for your Discord bot. There are three ways to create the actual code for your Discord bot:
- Program your own from scratch.
- Use a Discord bot creation service. Kite is a decent open-source platform that allows you to build a bot without writing code yourself. It will host your bots for you, and you can even host it on your own server if you want to.
- Use a pre-made Discord bot. You can find plenty of well-regarded, open-source Discord bots on GitHub, and we’ll be using that approach in this tutorial.
Once you have the code, there are a few steps you’ll need to follow:
1. Turn on Developer Mode in Discord
Go to the App Settings section in Discord, click Advanced, and then turn on Developer Mode. There will be a link in the description for the feature labeled Discord API. Click that too.
2. Create an app in the Discord Dev Portal
Clicking that link will take you to the Discord developer portal, where you can go to Applications to create a new app.
Next, name your app, and then click Create.
3. Add a bot to your app
Once you’ve created your app, you can change the basic info and details, like the icon.
On the same page, you’ll see a section called Privileged Gateway Intents. For the purposes of this tutorial, you want to turn them all on.
4. Copy your token
On the Bot page, copy your Token. This is a string of text that you’ll use to tell Discord that your bot belongs to you and the app you’ve created. Never share the token with anyone else, and make sure to save it in a safe place. You may need to hit the Reset Token button at this point.
That’s the last of the steps you need to take to set up your bot in Discord.
How to host a Discord bot on a VPS server
For this tutorial, we’re going to start off with a simple music bot. We looked for one with a comparatively simple setup process and selected MusicBot. More complex bots will require more setup and configuration, and the installation steps will vary depending on what kind of bot you’re using and what language it was coded in.
For this one, you’ll need:
- A VPS host running Linux
- An understanding of the command line interface
- A user account on the server with sudo (admin/root) access (though it’s best not to do this from the root account).
Note: All commands are run by pressing Enter after being typed out.
1. Log in to your server via SSH
Open up the Terminal app of your choice or the command prompt, and use SSH (secure shell) to log in. If you’re on Windows, you may need to install it via the Windows feature settings.
Log in with this command, replacing user with your username, and the IP address as necessary:
ssh user@123.456.789.10
You’ll then need to enter your password.
2. Download and install your bot
Here are the instructions for installing MusicBot on a Debian-based server (since Debian is a stable version of Linux that’s often used for servers). We’ve adapted the steps from the instructions provided by the bot’s authors.
Update system packages
You’ll first need to update system packages, with the following:
sudo apt-get update -y && sudo apt-get upgrade -y
This makes sure your system is up to date and everything is installed properly (noting that “sudo” runs commands with admin privileges). You’ll need to type in your user password.
Install dependencies
Next, you need to install the dependencies that MusicBot needs to run, with the following:
sudo apt install -y jq git curl ffmpeg build-essential libopus-dev libffi-dev libsodium-dev python3-full python3-dev python3-venv python3-pip nano
As you might guess from the package names, the bot is written in Python, which needs some extra software to run. We’ve added Nano (a simple command-line text editor) to the list, as you’ll need it later.
Set up the venv directory as ./MusicBotVenv
Python-based apps need to be run in virtual environments or “venv folders.” The following command will set up a virtual environment and create a new folder called “MusicBotVenv”:
python3 -m venv ./MusicBotVenv
Change into the venv directory and activate the virtual environment
Next, run these two commands one after the other:
cd MusicBotVenv
(“cd” lets you move from one folder to another)
source ./bin/activate
(activates the Python virtual environment)
Download the MusicBot files
This will use Git version control software to download the actual MusicBot files from GitHub and put them in a subfolder called MusicBot:
git clone https://github.com/Just-Some-Bots/MusicBot.git -b dev ./MusicBot
Next, change directory into the new folder with:
cd ./MusicBot/
Install the pip libraries
This will install extra Python dependencies for MusicBot inside the virtual environment:
python -m pip install -U -r ./requirements.txt
Exit the virtual environment
Next, run “deactivate” in the terminal. When you see (MusicBotVenv) disappear from the beginning of the line, you’ll know it worked.
3. Configure the bot
From the MusicBot directory, change into the config directory:
cd config
Copy the example options file into a new file with:
cp example_options.ini options.ini
(“cp” is the command to copy files. The next two elements are the name of the source file, and the name of the file once it’s been copied.)
Now use Nano to open the new file:
nano options.ini
Go to the credentials section using the arrow keys, and paste in your token after the = sign (in the terminal, you’ll most likely need to press Ctrl+Shift+V to paste).
Press Ctrl+S to save, and then Ctrl+X to exit.
4. Run the bot
Use this command to go back to the MusicBot folder:
cd ../
(“cd ../” goes to the parent folder of whichever folder you’re in.)
Then use this command to run the bot:
./run.sh
If the bot doesn’t tell you that it’s automatically stopped, then it’s running.
5. Set up autostart
Your VPS may occasionally go down for server maintenance. When that happens, your bot won’t automatically restart when the server does. Also, as things stand, your bot will stop running when you close the terminal window.
To fix this, look up how to create a “systemd service” for your bot or how to run commands on reboot with “crontab.” Make sure that everything is running before continuing.
6. Add the bot to your server
Get the Install Link from the Installation section of the Discord dev portal:
Then paste the link into your browser to install the app on your server. It will open either the Discord app on your device or in your browser to give you the following options:
If you then click on Add to Server, you’ll see the following:
From there, you should head to your server and try out the bot. That covers the basics of making and hosting a Discord bot for your own personal use, but depending on the bot and what you plan to do with it, it may require some further setup.
How to choose the best Discord bot hosting
The best Discord bot hosting service for your needs will depend on how many people you have on your server and how many servers you intend to run the bot on. If you intend to make the bot/Discord app publicly available, you’ll want to make sure that it's running on a fast VPS platform with affordable pricing.
You don’t need a lot of advanced features, however, as long as you have reliable performance. Hostinger is a solid bet and offers good VPS hosting options, and you might also consider Liquid Web VPS hosting.
Can you host a Discord bot for free?
Technically, yes. Services like Kite, which let you build Discord bots without code, will host the bots for you. There are also various free bot hosting services around, but they have varying reputations. Free hosts can also decide that your bot is too popular and start charging or collecting data. If you want a bot that you truly control, then it’s best to host it on a server that you pay for.
FAQs
What is the best Discord bot hosting?
The best Discord bot host is one that gives you full control. Most decent VPS providers will include the tools you need, but we recommend Hostinger and Liquid Web as good VPS options.
Is it safe to self-host a Discord bot?
Whether it’s safe to self-host a Discord bot depends on the quality of the bot’s code and how well you’ve secured your server. We recommend using a firewall and avoiding opening any more ports than you have to.
How much does it cost to host a Discord bot?
Discord bot and VPS web hosting costs vary from platform to platform, but you can get good deals with Hostinger, among other services that we’ve reviewed on All About Cookies.
Bottom line
Hosting a Discord bot isn’t simple, but it’s not at all impossible. If you want to do it yourself, it means learning how the Discord dev portal works, managing your own VPS server, learning how to install your bot’s dependencies on Linux, and potentially adding your bot/app to the Discord store.
This can be a lot of fun if you like tinkering, and if you don’t, there are code-free and pre-built bot hosting services available. Have fun, and we hope that this article gives you a solid place to start with creating and hosting your own Discord bot.