How to keep a Discord bot online 24/7
A bot is a program, and it is online only while that program runs. Close the terminal on your PC and the bot goes offline with it. A bot you coded yourself belongs on a small rented server with a process manager. A bot without your own code can be hosted for you. Free code hosts sit in between, and most of them come with a catch.
Updated 2026. gada 18. novembris9 min read
On this page
The short version
- A bot you coded needs a machine that never sleeps, usually a small rented server (VPS) with a process manager such as pm2.
- Free tiers of code hosts tend to sleep, expire or change their terms. They are fine for experiments. A community shouldn't depend on them.
- A bot you set up on SCNX is hosted by us from the moment you create it. SCNX can't run your own code.
What you need
- For your own code: a rented Linux server and some patience with the command line
- For a hosted bot: a Discord account and a server you own
Why a bot goes offline
Your bot holds an open connection to Discord. Messages, joins and button presses arrive over that connection, and the bot's answers go back the same way. When the program stops, the connection closes and Discord shows the bot as offline a little later.
The program stops for ordinary reasons: the computer goes to sleep, Windows installs an update, the internet drops for a minute, or an error crashes the code and nobody starts it again. Keeping a bot online means solving two things: a machine that is always on, and something that restarts the program when it falls over.
Where a bot can run
| Cost | The catch | |
|---|---|---|
| Your own computer | Electricity | Offline whenever the PC sleeps, updates or loses its connection |
| Free tier of a code host | Nothing | Sleeps when idle, runs out of free hours or disappears |
| Rented server (VPS) | A small monthly fee | You install, update and watch it yourself |
| Hosted bot on SCNX | Free on our Starter plan | No own code. You work with modules and custom commands |
Your own computer is the right place while you are still writing the bot. For a community that expects the bot at three in the morning, it is one of the other three.
Free code hosting, and what breaks
Older tutorials send you to free tiers of general code hosts. Many of those offers are gone. Heroku ended its free plans in November 2022, and Replit removed its Always On feature at the start of 2024. What is left usually comes with one of these problems:
- The project sleeps when idle
- Free web hosting wakes a project when someone visits its address. A Discord bot has no visitors. It waits on its connection to Discord, so once the host puts it to sleep nothing wakes it again. Workarounds that ping the project every few minutes last until the host changes its rules.
- The free hours or credits run out
- Some hosts give you a monthly budget of hours or a one-time trial credit. A bot that runs all month uses about 730 hours, which is more than most free budgets.
- Files don't survive a restart
- On many free tiers the disk is wiped whenever the project restarts. A bot that keeps levels or warnings in a local file starts from zero each time, unless you move the data to a hosted database.
- You share an address with strangers
- Discord limits requests per IP address as well as per bot. On a shared free host, other people's bots use the same address, and their mistakes can slow yours down.
None of this makes free hosting useless. It is fine for learning and for a bot only your friends use. Read the current terms before you build a community on it, because they change often.
If you wrote the code: a VPS with pm2
For a bot you programmed, a small virtual server is the dependable answer. The smallest plan of most providers is enough for a bot on a handful of servers and costs a few euros or dollars a month. The steps below are for Ubuntu or Debian and are the same with every provider.
Rent the server and update it
Pick a small Linux plan, log in over SSH and run
sudo apt update && sudo apt upgrade. Create a normal user for the bot so it doesn't run as root.Install the runtime and copy your code
That is a current LTS release of Node.js for discord.js, or Python 3 for discord.py. Copy the project with
git cloneand install its dependencies withnpm installorpip install -r requirements.txt.Keep the token out of the code
Put the bot token in an environment variable or a
.envfile, and list that file in.gitignore. A token in a public repository is found within minutes. Discord resets tokens it spots on GitHub, and your bot stays offline until you enter the new one.Start the bot under a process manager
Install pm2 with
npm install -g pm2, then runpm2 start index.js --name bot. For Python it ispm2 start bot.py --name bot --interpreter python3. pm2 restarts the bot whenever it crashes.Make it survive a reboot
Run
pm2 startupand execute the command it prints, thenpm2 save. Skip this step and the bot stays offline after the next reboot of the server until someone logs in.Check the logs and plan for updates
pm2 logs botshows what the bot printed before it crashed. The system, the runtime and your libraries need updates from time to time. Plan an hour a month, and keep a copy of your database somewhere else.
A systemd service does the same job as pm2 and is already on the server. Use whichever you are comfortable with. What matters is that something restarts the bot after a crash and after a reboot.
One Discord setting trips up most first deployments: if your code asks for the members, presence or message content intents, they have to be switched on under Privileged Gateway Intents on the Bot page of the Developer Portal. Otherwise the bot quits at login with a disallowed intents error.
If you have no code: a hosted bot
A bot you create on SCNX runs on our servers in Europe from the first minute. You don't install or upload anything. The parts of the VPS list above still exist, we just do them:
- Crashes
- If the bot's process crashes, the host system restarts it. The status card shows that while it happens.
- Updates
- When a new version of the bot is out, the status card tells you. Update bot installs it. The bot restarts and is offline for a moment.
- Changes without downtime
- After changing settings you use Reload configuration. The bot picks them up and stays online.
- Logs
- Log and Error-Log on the status card show what the bot did and why something failed, for example a missing permission in a channel.
- Where it runs
- The status card names the server your bot runs on, and you can move it to another one of our Bot-Hosts from there.

Screenshot from our test server. Your dashboard may look different.
What you give up is the code. You can't log in to the machine or run your own program. Features come from the bot's modules and from custom commands you build in the dashboard. We have been hosting bots this way since 2020.
Your own code or a hosted bot
| Your code on a VPS | Hosted bot on SCNX | |
|---|---|---|
| Features | Whatever you can write | 65+ modules and custom commands |
| Setup | Server, runtime, process manager | A token and a few clicks |
| Crashes and updates | Yours to handle | Handled by us |
| Cost | A monthly server fee | Free on our Starter plan, with an ad check-in |
| Public bot for many servers | Possible | No, one bot per community |
What free means on SCNX
Our Starter plan hosts your bot 24/7 and costs nothing. It is paid for by ads. Every 14 days someone on your team opens the dashboard and watches a short ad video, and that check-in keeps the bot online. If nobody does, the bot goes offline until the video has been watched.
On our paid plans the bot stays online for as long as the plan is active, and the check-in and the ads are gone. The plans page compares them.
If your bot is offline right now
For a bot on your own server, start with pm2 status and pm2 logs. For a bot on SCNX, open its status card. The usual causes:
- The process crashed and nothing restarted it
- On a VPS this means the process manager is missing or was not saved. Go back to the pm2 steps. On SCNX the host restarts the bot by itself.
- The token is no longer valid
- Someone reset it in the Developer Portal, or Discord did because it leaked. Create a new token. On a VPS, put it in your environment file and restart. On SCNX, the status card shows Discord rejected your bot token with a button to enter the new one.
- The intents are switched off
- The bot asks for privileged intents that are off in the Developer Portal. Turn them on under Privileged Gateway Intents and start the bot again.
- The free plan ran out
- On our Starter plan the bot stops when the ad check-in was missed. Watch the short video in the dashboard and start the bot.
- The bot was removed from the server
- A bot that was kicked can't do anything. On SCNX the dashboard says Your bot was removed from your server and offers the invite again.
- Discord itself has a problem
- If several bots are offline at once, check discordstatus.com before you change anything.
Coming from a bot you coded
SCNX does not run your own code, so you can't upload an existing bot. What you can do is rebuild its features: most of the common ones exist as modules, and your own logic can be built with Custom Commands V3, which is in beta.
If an AI assistant wrote your bot and you are the one keeping it alive, the page on coming from AI-written bot code goes through the differences. And if you enjoy running your own server, there is nothing wrong with staying on a VPS.
Common questions
- Can I host a Discord bot for free?
- Yes, with conditions everywhere. On SCNX, our Starter plan hosts your bot for free and asks for a short ad video every 14 days. Free tiers of code hosts usually limit hours or put idle bots to sleep.
- Can I upload my own bot code to SCNX?
- No. SCNX hosts the bots you create on SCNX. For your own code you need a server of your own.
- Do I have to leave my computer on?
- Only if the bot runs on it. A bot on a VPS or on SCNX keeps running when your computer is off.
- Can I host a bot on a Raspberry Pi at home?
- Yes, a bot for one community runs fine on one. It is online as long as the Pi has power and your home internet works, and you still need a process manager such as pm2 so it restarts after a crash or a power cut.
- Why does Discord show my bot as offline although it is running?
- Discord can take a few minutes to update the status after a start or a stop. If the dot stays grey for longer, the bot is not connected. Check the logs for a token or intents error.
- Does a bot on SCNX stay online when I close the dashboard?
- Yes. The dashboard is only where you change settings. The bot runs on our servers whether you are logged in or not.
- What happens if a host has a problem?
- On SCNX, your bot's configuration and data are backed up and we restore them if a host fails. Outages and maintenance are announced on our status page.
Start with a free bot
Log in with Discord, add your server and create your bot. The dashboard walks you through each step.
Get started for freeFree on our Starter plan. A short ad video every 14 days keeps the bot online.