How to host a discord.js bot 24/7
Get a discord.js bot running around the clock on ESN, even when your computer is off. About 10 minutes from zip to online.
Before you start #
You need an ESN account (create one) and a bot plan from $0.50/month on the plans page. Most small bots run fine on Nano (256 MB) or Starter (512 MB); see how much RAM a bot needs.
- Your bot works on your own computer with
node index.js(or your start file). - Your project has a
package.jsonthat listsdiscord.jsunder dependencies. If it doesn't, runnpm install discord.js dotenvonce on your computer and it will be added. - You have your bot token from the Discord Developer Portal. New to this? See create a bot and get its token.
Get your code ready #
Keep the token out of your code. Put it in a .env file and load it with dotenv:
require('dotenv').config();
const { Client, GatewayIntentBits, Events } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.once(Events.ClientReady, (c) => {
console.log(`Logged in as ${c.user.tag}`);
});
client.login(process.env.DISCORD_TOKEN);The .env file has one line: DISCORD_TOKEN=your-token-here. If your bot reads message text, add GatewayIntentBits.GuildMessages and GatewayIntentBits.MessageContent and turn on Message Content in the Developer Portal (see intents explained).
Upload it to ESN #
- Open your server from the panel dashboard. It should be set up as Discord bot (Node.js).
- Go to Files. Zip your project without the
node_modulesfolder, upload the zip and choose Unarchive.package.json,.envand your start file must sit in the top folder, not inside a subfolder. See uploading files. - Go to Startup. The Main JavaScript File is
index.jsby default. Change it if your bot starts from another file, likebot.jsorsrc/index.js. - On the same page, the Docker Image box lets you pick Node.js 22 or 24. Current discord.js v14 runs on both.
Start it and keep it online #
- Go to Console and press Start. On every start the server runs
npm installand thennodeon your start file, so you never uploadnode_modules. - Wait for your own ready line, for example Logged in as MyBot#1234. That is the real sign your bot is online.
- Close the tab. The bot keeps running on ESN's servers when your PC is off.
- To update the bot later, upload the changed files and press Restart. Need it to restart on a timer? Use schedules.
Note: the panel can show Starting even while your bot is running fine. The console output is the real answer.
Common discord.js errors #
- TokenInvalid / "An invalid token was provided": the token in
.envis wrong or was reset. Reset it in the Developer Portal and paste the new one. See fix an invalid token. - "Valid intents must be provided": add an
intentsarray tonew Client(). See this fix. - "Used disallowed intents": turn on the matching privileged intent in the Developer Portal. See privileged intents required.
- "Cannot find module": the package is missing from
package.json, or your start file path is wrong on the Startup page. - More: common bot errors and bot online but not responding.
FAQ #
Do I upload node_modules?
No. The server runs npm install from your package.json on every start, so leave node_modules out of your zip.
Which Node.js version should I pick?
The Startup page offers Node.js 22 or 24. Either works with current discord.js v14.
Will my discord.js bot stay online when my PC is off?
Yes. It runs on ESN's servers, not your computer.
How much does it cost?
ESN bot hosting starts from $0.50/month. All plans are on panel.esnoffical.com/plans.
Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 3, 2026.