How to put a Discord bot online with App hosting
Add the bot's repository, save its token as a variable and press Deploy. A bot needs no web address. App hosting is in beta.
- Audience
- New to running a server
- Last checked
- Steps
- 8
- Reading time
- 6 min
To put a Discord bot online with App hosting, you add the bot's repository in the control panel, save its token as a variable and press Deploy. We build the code and start the bot. It shows as online in Discord once it has logged in.
You don't need to write code or a Dockerfile. If a friend wrote the bot, you need two things from them: the link to its repository and the name the code reads the token from.
On Hostsrc
App hosting is in beta. Order Hobby or Pro and Apps shows in the panel once your payment is confirmed. A bot at 150 MB of RAM, 2% of a vCPU and 1 GB of disk costs about €0.90 a month, inside the Hobby plan's €5/month, which includes €5 of usage. Final price, no VAT added.
Before you start
- A Hostsrc account with App hosting turned on. It's in beta, so order Hobby or Pro first.
- The bot's code in a repository: on GitHub, or public on GitHub, GitLab or Codeberg.
- The bot's application in the Discord Developer Portal, or the friend who made it.
Steps
Step 1: Copy your bot's token
Open the Discord Developer Portal (external site, opens in a new tab) and pick your bot's application. On the Bot page, press Reset Token and copy the new token. Discord shows it once, so keep it somewhere private until step 5.
Resetting makes the old token stop working. If the bot still runs somewhere else, such as a friend's computer, it goes offline there. If a friend owns the application, ask them to do this step and send you the token privately.
Warning
The token is the bot's password. Anyone who has it can control your bot. Never put it in the code, a screenshot or a chat message.
Step 2: Get the repository link and the token's name
The bot's code has to be in a Git repository. If a friend wrote it, ask them for two things:
- The link to the repository, for example
https://github.com/your-friend/your-bot. - The name the code reads the token from. It is often
DISCORD_TOKEN, but it can beTOKEN,BOT_TOKENor another name.
A developer finds the name where the bot logs in. In these two examples it is
DISCORD_TOKEN.// JavaScript, discord.jsclient.login(process.env.DISCORD_TOKEN); # Python, discord.pybot.run(os.getenv("DISCORD_TOKEN"))Note
If the token is written in the code or in a file in the repository, anyone who can see the repository can see it. Ask the developer to read it from a variable instead, then reset the token (step 1).
- The link to the repository, for example
Step 3: Open Apps in the control panel
Sign in at control.hostsrc.com (opens in a new tab) with your Hostsrc account. In the header, switch from Servers to Apps. Your game servers stay under Servers.
The switch shows once App hosting is on for your account. Apps opens on Projects, which is empty the first time.
Step 4: Add the bot from its repository
On Projects, press New and choose where the code is:
- Connect GitHub, then GitHub, for a private repository, or to deploy every push by itself. GitHub asks which repositories to share. Allow the bot's repository. You come back to Apps: press New again, choose GitHub Repository and pick the bot's repository.
- Public Repository for a public link on GitHub, GitLab or Codeberg. Paste the link and pick the repository when it shows.
The panel makes a project named after the repository, with the bot in it as a service. The service opens on Variables. Nothing runs until you press Deploy in the next step.
Step 5: Add the token and deploy
On Variables, press New variable. Type the name from step 2, such as
DISCORD_TOKEN, and paste the token as its value. The name must match exactly, capitals included.Add any other variables the bot needs the same way. If the repository has a
.env.examplefile, the panel lists its names under Suggested variables. To paste several lines at once, open Raw editor and write oneNAME=valueper line.Press Save variables, then Deploy. Saving alone doesn't start or update the bot.
DISCORD_TOKEN=paste-your-token-hereNote
A change to a variable applies with the next deploy. After you change one later, press Deploy again.
Step 6: Watch the build
Open Deployments. The new deployment shows BUILDING while we build the code and ACTIVE once the bot runs. Press View logs on it to follow the build step by step.
We detect the language from the repository, so you don't need a Dockerfile. The usual files are
package.jsonfor a Node.js bot andrequirements.txtfor a Python bot.Step 7: Check that the bot is online
Open Logs. Most bots print a line once they have logged in to Discord, such as
Logged in as YourBotorReady. The exact words come from the bot's code. Then open your Discord server: the bot shows as online in the member list.A bot needs no web address. The service shows Private service instead of one, and that is right for a bot. If the panel says the service listens on a port and offers a domain, you only need one for a web dashboard.
Step 8: Update the bot, or go back
With GitHub connected, every push to the bot's branch builds and deploys by itself. With a public link, press Deploy latest on Deployments to pull new commits.
To go back to an earlier version, open History on Deployments and open an earlier deployment. Choose Rollback to this in its menu and confirm with Roll back.
Stop takes the bot offline and Start brings it back. Restart starts it again without a new build.
Troubleshooting
My bot stays offline in Discord
Open Logs and read the last lines. A token error means the variable is wrong. discord.js says TokenInvalid, and discord.py says LoginFailure. Check these three things:
- The variable's name is exactly what the code reads, capitals included.
- The value is the whole token, with no spaces.
- It is the newest token, if you reset it.
Then save the variables and press Deploy. If the panel shows Crashed, press See the last lines before it stopped.
The bot runs but isn't in my Discord server
A bot joins a server through its invite link. Ask the person who made the bot for the link, or create one in the Developer Portal under OAuth2.
The build fails
Open the failed deployment and read its build logs. The last lines name the problem. Two causes are common:
- The repository is private and GitHub isn't connected. A public link can't read a private repository, so use Connect GitHub (step 4).
- The build can't tell how to start the bot. Set Start command in Settings, under Deploy, for example
node index.jsorpython main.py. Then press Deploy.
My repository isn't in the list
GitHub only shares the repositories you allowed. In the repository list, choose Configure repository access, allow the bot's repository on GitHub, then come back and press New again.
The bot stops after a while
Open Logs and read the lines before it stopped. A crash in the bot's code shows there with its error.
If Metrics shows memory climbing to the service's limit before it stops, the bot ran out of memory. Raise its memory in Settings, under Scale, in Resources, up to your plan's limit per service. Or ask the developer to make the bot hold less in memory.
Links
- Discord Developer Portal (external site, opens in a new tab)
your bot's application, its token and its invite link
- Hostsrc control panel (opens in a new tab)
sign in, then switch to Apps
- App hosting
plans and prices, with a link to order each plan
App hosting
Hobby €5/month
Includes €5 of usage every month. In beta. Final price, no VAT added.
Choose a planDiscord
Ask other admins and our team.
Join our Discord (external site, opens in a new tab)Related guides
How to host a discord.py bot
Put the bot in a GitHub repository with requirements.txt, read the token from a variable, connect the repository and press Deploy.
7 steps4 min readNew to running a server
How to deploy an app you built with AI
Push the code to GitHub, connect the repository once, add the app's variables and press Deploy. Every push after that deploys by itself.
7 steps5 min readNew to running a server