Free hosting
Minecraft JavaMinecraft BedrockPaperMCFabricForgeGeyserMCTerrariaFactorioHytaleDiscord botsRLCraftCobblemonBetter MCCreate
Go premium

No hibernation, no timers, 5 GHz CPUs and up to 32 GB RAM.

From €1.99/month →
Tools & help
RAM calculatorMOTD generatorServer status checkerserver.properties generatorColor codesGuidesDiscord community
Language
EnglishNederlandsEspañolFrançaisDeutschItalianoPortuguêsLatviešuPolskiSuomiNorskRomânăPortuguês (BR)Türkçeहिन्दी
Start free
Discord · Node.js

How to Host a discord.js Bot for Free (Node.js, 2026)

A step-by-step guide to running a discord.js bot on a server instead of your PC: project files, slash commands, GitHub deploys and keeping it online.

FreeGameHost logo FreeGameHost Guides Updated 7 min read

Quick answer

  1. Include a package.json; the server runs npm install on every start.
  2. Load the token from .env with dotenv.
  3. Set the bot file (default index.js) on the Startup page and press Start.

Project files#

package.json
{
  "name": "my-bot",
  "type": "module",
  "dependencies": {
    "discord.js": "^14.16.0",
    "dotenv": "^16.4.0"
  }
}
index.js
import "dotenv/config";
import { Client, Events, GatewayIntentBits } from "discord.js";

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.once(Events.ClientReady, (c) => console.log(`Logged in as ${c.user.tag}`));

client.on(Events.InteractionCreate, async (i) => {
  if (i.isChatInputCommand() && i.commandName === "ping") await i.reply("pong");
});

client.login(process.env.DISCORD_TOKEN);

Register slash commands#

Slash commands are registered once with Discord's REST API, separate from the bot itself. Add a small script and run it whenever you change commands:

deploy-commands.js
import "dotenv/config";
import { REST, Routes, SlashCommandBuilder } from "discord.js";

const commands = [new SlashCommandBuilder().setName("ping").setDescription("Replies with pong").toJSON()];
const rest = new REST().setToken(process.env.DISCORD_TOKEN);
await rest.put(Routes.applicationCommands(process.env.CLIENT_ID), { body: commands });
console.log("Commands registered");

On the server, set the bot file to deploy-commands.js, start it once, then set it back to index.js. Add CLIENT_ID (your application ID) to .env.

Deploy#

  1. Create the bot server

    On free Discord bot hosting, create a server and choose Node.js. Pick the Node version (up to Node 24) on the Startup page; discord.js 14 needs Node 18 or newer.

  2. Upload or use GitHub

    Upload your files with the file manager or SFTP (skip node_modules), or set Git Repo Address and Git Branch and reinstall. Upload .env by hand.

  3. Start

    Press Start. The Console shows npm install, then "Logged in as ...".

Free Node.js bot hosting256 MB RAM, Node up to 24, GitHub deploys. No credit card.
Host my bot

Troubleshooting#

  • "Cannot use import statement outside a module": add "type": "module" to package.json, or use require.
  • "Used disallowed intents": turn on the intent in the Developer Portal or remove it from your code.
  • Commands don't show: run the deploy script again, and check CLIENT_ID.

Bot servers don't sleep. Free servers run on a timer: each click on Renew adds 12 hours, up to 48 hours stored, as often as you like. Python instead? See how to host a discord.py bot.

Related: Free Discord Bot Hosting  •  Free Minecraft Server Hosting

Frequently asked questions#

Which Node.js version do I need?

discord.js 14 needs Node 18 or newer. The bot server lets you pick Node versions up to 24.

Do I upload node_modules?

No. Upload package.json; the server runs npm install on every start.

How do I update the bot from GitHub?

Set the Git repo and branch on the Startup page and turn on Auto Update. Every restart pulls the latest code.