You wrote your bot, it runs on your own machine, it answers commands — but the moment you close the terminal, it goes silent. That is exactly where Discord bot hosting comes in: a hosting setup that keeps your bot up 24/7 and online for as long as you want, without your laptop being involved. In this article I compare VPS, Railway, Pterodactyl panels and the free options on cost, uptime and ease of setup — so by the end you will know exactly which one makes sense for your situation.
Why does a bot need an always-on server?
A Discord bot is really a long-running program that opens a persistent WebSocket connection to Discord's gateway. To receive events (messages, buttons, slash commands) that connection has to stay alive. Running it on your own machine creates three problems: the bot dies when you shut the computer down, the connection drops when your internet hiccups, and keeping a desktop on around the clock makes little sense for power and performance. The fix is to run the bot on a server that is always on.
When choosing, I look at three things: uptime (how reliably the bot stays running), cost, and control / ease of setup. These usually pull against each other — the cheap, easy option often gives you the least control.
Free options: how far do they get you?
Free tiers look tempting for hobby bots, but you need to know their limits clearly. Over the years many free "always-on" services have either shut down or moved to a sleep-after-idle model. The realistic free options today are:
- Oracle Cloud Always Free: offers small ARM/x86 VPS instances that genuinely stay free. Technically the most powerful free option, but the setup is entirely on you (you manage Linux) and account approval can sometimes be a hassle.
- Platforms like Railway / Render: give a monthly free usage credit. Setup is easy, but the bot stops once the credit runs out, and an always-running bot can burn through that credit quickly.
- Replit: fine for quick experiments, but reliable persistent "always-on" execution is no longer dependable on the free plan; I would not recommend it for a serious bot.
In short: free tiers are good for learning and small test bots. For a bot with a few hundred users that is expected to stay online, they are usually not enough.
Railway and PaaS: the easiest start
Railway, Render and similar PaaS (Platform as a Service) solutions are ideal if you do not want to manage a server from scratch. You connect a GitHub repo, the platform builds and runs the code, and you only define a start command and your environment variables. Instead of hardcoding your bot token, you pass it as an environment variable:
// index.js
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.login(process.env.DISCORD_TOKEN);
All you need is a start script in package.json:
{
"scripts": {
"start": "node index.js"
}
}
The upside: you are live within minutes, with no server updates or security patching to worry about. The downside: cost can climb quickly as usage grows, and you have limited control over the underlying infrastructure.
VPS: the most control, the best cost/performance
If your bot has grown, or you run several bots/services, a small VPS (for example Hetzner, DigitalOcean or Contabo) is usually the most sensible choice. For a few dollars a month you get a Linux server with root access and run whatever you like on it. To keep the bot running without going down, I recommend pm2 as a process manager:
# with Node.js installed:
npm install -g pm2
# start the bot and give it a name
pm2 start index.js --name discord-bot
# survive server reboots automatically
pm2 startup
pm2 save
For Python bots (discord.py) the approach is the same; instead of pm2 you can write a systemd service or use pm2 start bot.py --interpreter python3. The big win with a VPS: the resources are entirely yours, cost is fixed and predictable, and you can keep the database and a web panel on the same machine. In return, basic Linux administration (updates, firewall, SSH keys) is your responsibility.
Pterodactyl: managing multiple bots from a panel
Pterodactyl is an open-source game/application server panel that you install on top of your own VPS. It lets you start and stop each bot inside a Docker container from a web interface, watch its logs and set resource limits. It is not "hosting" by itself — it adds a management layer on top of an existing server. It adds value when:
- You run multiple bots or different projects on the same server and want each isolated.
- You want to hand bots over to others (a team, a client) without giving SSH; you can grant limited panel access instead.
For a single bot, installing Pterodactyl is over-engineering — plain pm2 is more practical in that case.
Which should you pick? A quick decision guide
- Just learning / test bot: a free tier (Railway credit or Oracle Always Free).
- You want no server management, fast deploy: a PaaS like Railway/Render.
- Serious, growing bot / fixed cost: a small VPS +
pm2. - Many bots, team/client management: a VPS + the Pterodactyl panel.
Token security follows the same rule everywhere: never put the token in your code or Git repo, always use an environment variable (.env), and regenerate it immediately from the Discord Developer Portal if it ever leaks.
Frequently Asked Questions
How much RAM do I need to run a Discord bot?
Most small-to-mid bots run comfortably on 256–512 MB of RAM. Music bots (audio streaming) or bots with heavy database use want more; a 1 GB VPS handles the large majority of these workloads easily.
Can I stay online 24/7 with free hosting?
To a limited extent, yes. Oracle Always Free gives a real VPS so it is continuous, but the setup is on you. On credit-based PaaS the bot stops when the credit runs out at month's end; for a true 24/7 guarantee a paid plan or a VPS is more reliable.
I don't know how to manage a VPS — should I still get one?
If you have no basic Linux/SSH knowledge, a PaaS is less stressful to start with. That said, bringing a bot up with pm2 is an easy skill to learn, and in the long run it pays off in both cost and control.
Looking for the right hosting setup for your bot? Whether it is writing a Discord bot from scratch or moving your existing bot to a VPS to run 24/7 without issues, I can set it up end to end. Get in touch and let's pin down what you need.