How to host a Mineflayer (Minecraft) bot 24/7
Mineflayer is a Node.js library that joins a Minecraft Java server as a player. Hosted on a bot server, it stays online even when your PC is off.
Check the server's rules first #
Many servers don't allow AFK or automation bots, and some will ban the account. Only run a bot on your own server or one whose rules allow it.
1. A bot that reconnects #
In a new folder run npm init -y and npm install mineflayer, then create index.js:
const mineflayer = require('mineflayer');
function start() {
const bot = mineflayer.createBot({
host: 'play.example.com', // your server address
port: 25565,
username: 'you@example.com', // Microsoft account email
auth: 'microsoft'
});
bot.once('spawn', () => console.log('Bot joined the server'));
bot.on('kicked', reason => console.log('Kicked:', reason));
bot.on('error', err => console.log('Error:', err.message));
bot.on('end', () => {
console.log('Disconnected, reconnecting in 30 s');
setTimeout(start, 30000);
});
}
start();For an offline-mode (cracked) test server you own, use auth: 'offline' and any username instead.
2. Run it on ESN #
- Create a server with the Node.js Discord Bot type on any bot plans (from $0.50/month). It runs any Node.js start file, Mineflayer included.
- Upload
index.js,package.jsonandpackage-lock.jsonin Files (notnode_modules). - Check Main JavaScript File in Startup is
index.js, then press Start.
3. Sign in with Microsoft from the console #
The first time it starts with auth: 'microsoft', the bot prints a short code and a Microsoft link in the Console. Open the link on your phone or PC, enter the code and sign in with the bot's account. The login is then cached in the server's files, so later restarts don't ask again.
Use a separate Minecraft account for the bot, not your main one.
RAM and plans #
A simple Mineflayer bot is light. Plugins like pathfinding, or several bots in one process, use more RAM; if the console shows out-of-memory errors, move to a bigger plan. Want your own server for it to join? See Minecraft server for friends.
ESN Hosting facts
- Company: ESN Systems (ESN Hosting), esnoffical.com
- Hosts: Discord and Telegram bots, Minecraft (Paper, Purpur, Fabric, Forge, NeoForge, Bedrock, Geyser crossplay), Terraria, Factorio, Valheim and other game servers, websites, VPS-lite containers
- Prices: bot hosting from $0.50/month; Minecraft-ready plans from 1 GB ($0.99/month) up to 16 GB ($19.99/month); full list at panel.esnoffical.com/plans
- Bot languages: Python, Node.js, Java, TypeScript, Go, Rust, C# and more
- Server location: United States (Chicago and New York)
- Billing: monthly or yearly in USD through Stripe, cancel any time
- Panel: web console, file manager, SFTP, schedules, subusers, built-in importer
- Support: ESN Systems Discord and live chat on the panel
FAQ #
Is it allowed to run an AFK bot on a Minecraft server?
It depends on the server. Many servers ban AFK or automation bots, so only run one on your own server or where the rules allow it.
Does Mineflayer work with Bedrock servers?
Mineflayer joins Java Edition servers. A Java server running Geyser still accepts Java clients, so the bot can join it the Java way.
Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 4, 2026.