How to Host a Discord Bot 24/7 (Node.js, Python & Java)
Where to host a Discord bot and how to keep it online 24/7: hosting options compared, requirements for Node.js, Python and Java bots, deployment steps, auto-restart, and the errors that take bots offline.

A Discord bot is a program that must be running somewhere, all the time, with a stable connection to Discord. To host one 24/7 you need a machine that stays on, the right runtime (Node.js, Python or Java), your bot's dependencies installed, the token stored as an environment variable, and something that restarts the process when it crashes. Your own PC can do it for testing; for anything people rely on, use a VPS, a bot hosting panel or a container platform.
This guide compares the hosting options, lists what a bot needs to run, walks through a deployment on a hosting panel, explains how to keep the bot online, and covers the errors that most often take bots offline.
Where can you host a Discord bot?
| Option | Good for | Drawbacks |
|---|---|---|
| Your own PC | Development and testing | Goes offline when the PC sleeps, restarts or loses connection; your home IP is exposed if the bot serves web requests |
| Raspberry Pi or home server | Hobby bots, learning Linux | You maintain the hardware, the OS, the network and backups; residential connections drop |
| VPS | Developers comfortable with a terminal | Full control, but you install the runtime, set up a process manager, patch the OS and watch resources yourself |
| Bot hosting panel (upload files, pick a start command, use a web console) | Most bot owners who want it online without managing a server | Less control over the OS; resources are fixed per plan |
| Container / PaaS platforms | Teams that already deploy with Git and containers | Free tiers typically sleep or cap hours; pricing scales with usage; some platforms are built for web apps rather than long-running processes |
| "Free 24/7" hosts | Nothing you depend on | Sleep timers, shared IPs that get rate-limited, sudden shutdowns, and in some cases token theft |
The deciding questions are: does the machine stay on, does the process restart when it dies, can you read the logs, and can you update the code without downtime you care about. Any option that answers yes to all four will work.
What a Discord bot needs to run
Runtime
- Node.js bots (discord.js, Eris, Oceanic): a current Node.js LTS release. discord.js v14 requires Node.js 18 or newer; check your library's documentation for the exact minimum.
- Python bots (discord.py, nextcord, Pycord, hikari): Python 3.8 or newer for current library versions; most new projects use 3.10+.
- Java bots (JDA, Javacord, Discord4J): the Java version your library and build require, typically Java 17 or newer for modern setups.
Match the version you developed on. A bot that runs on Node 20 locally may use syntax that Node 16 rejects.
Dependencies
Ship a manifest, not a node_modules or venv folder:
- Node.js:
package.jsonwith a lockfile; install withnpm ci(ornpm install). - Python:
requirements.txt(orpyproject.toml); install withpip install -r requirements.txt. - Java: a built jar (
mvn packageorgradle build) that includes dependencies, or the build files so the host can build it.
Token and secrets
Never hard-code the bot token. Read it from an environment variable (DISCORD_TOKEN) or a .env file that is excluded from Git. If a token is ever pushed to a public repository or pasted in a screenshot, regenerate it in the Discord Developer Portal immediately; leaked tokens are harvested within minutes.
Gateway intents
Discord gates some data behind privileged intents: message content, server members and presences. Enable the ones your bot uses in the Developer Portal (Bot → Privileged Gateway Intents) and request the same ones in code. A mismatch produces the "Used disallowed intents" error at startup.
A start command
The host needs to know how to launch the bot:
- Node.js:
node index.jsornpm start - Python:
python3 main.pyorpython3 -m bot - Java:
java -jar bot.jar
If your project has a build step (TypeScript, bundlers), either build before uploading or make the start command run the build first.
Deploying on a bot hosting panel, step by step
Panels differ in appearance, but the flow is the same on LuxuryNodes and most other hosts:
- Create the server and pick the runtime (Node.js, Python or Java) and the version that matches your project.
- Upload the project with the panel's file manager (or FTP/SFTP where the host provides it). Include
package.jsonorrequirements.txt; leave outnode_modules, virtual environments and any local.envwith real secrets. - Provide the secrets. Set
DISCORD_TOKENand anything else your config reads (database URLs, API keys) as environment variables if the panel supports them, or upload a.envfile next to the code that your bot loads at start and that never goes into Git. - Install dependencies. Many panels run
npm installorpip install -r requirements.txtautomatically at start; otherwise run it once from the console. - Set the start command to the one your bot uses.
- Start the bot and read the console. A healthy start logs the bot's login (for example
Logged in as BotName#1234). Fix any error before moving on; the next section lists the usual ones. - Enable auto-restart if the panel offers it, so a crash or a Discord disconnect that the library cannot recover from brings the process back.
- Test in Discord: run a command, check that slash commands registered (global commands can take up to an hour to appear; guild commands are instant), and watch the console for exceptions.
Keeping the bot online
- Auto-restart on crash. On a panel this is a setting; on a VPS use
systemd,pm2(Node) or a supervisor. Without it, the first unhandled exception at 3 a.m. takes the bot down until you notice. - Do not restart in a loop. If the bot crashes immediately on start (bad token, missing intent), a restart loop hammers Discord's gateway and can get the bot rate-limited. Fix the cause; add a delay between restarts if your tooling allows it.
- Let the library reconnect. discord.js, discord.py and JDA all handle gateway reconnects and resumes. Do not write your own reconnect logic unless you know why.
- Log to files or the console, and read them. Most "the bot randomly goes offline" reports are an exception in a command handler that nobody logged.
- Size memory realistically. A small bot in Node.js or Python typically sits at a few hundred megabytes. Caching members or messages, image processing, or music streaming raises that quickly; watch the panel's memory graph for a day before choosing a plan.
- Shard when required. Discord requires sharding once a bot is in 2,500 or more servers. Libraries provide sharding managers; the host just needs enough memory for the number of shard processes.
- Pin versions and update deliberately. Lockfiles keep a reinstall from pulling a breaking library update at the worst time.
Common errors that take a bot offline
| Error | Meaning | Fix |
|---|---|---|
TokenInvalid / Improper token has been passed / LoginFailure |
The token is wrong, has whitespace, or was regenerated | Copy a fresh token from the Developer Portal into the environment variable; restart |
Used disallowed intents |
Code requests a privileged intent that is not enabled in the portal | Enable it under Bot → Privileged Gateway Intents, or stop requesting it |
Cannot find module 'discord.js' / ModuleNotFoundError: No module named 'discord' |
Dependencies were not installed on the host | Run npm ci or pip install -r requirements.txt; make sure the manifest was uploaded |
SyntaxError: Unexpected token on start |
Runtime version older than the code requires | Select a newer Node.js or Python version |
EADDRINUSE |
The bot also runs a web server on a port that is taken | Use the port the host assigns (often from an environment variable) or disable the web server |
429 Too Many Requests |
Rate limited, often from a restart loop or a command spamming the API | Stop the loop; add caching or backoff to the offending code |
| Bot online but slash commands missing | Commands not registered, or registered globally and not yet propagated | Register guild commands for testing; wait for global propagation |
| Process killed without an error | Out of memory | Check the memory graph; reduce caching or move to a larger plan |
Paste the exact console line into a search engine or the library's support server; these messages are standardised across thousands of bots.
Python vs Node.js hosting: anything different?
Not much, from the host's side. Both are long-running single processes that need their runtime, their dependencies and a start command. Differences that matter in practice:
- Python projects more often forget
requirements.txt; Node projects more often uploadnode_modulesbuilt on a different OS. Ship the manifest, install on the host. - Python's
asyncioand Node's event loop both block on CPU-heavy work (image generation, large JSON parsing). Offload it or expect the bot to lag during those operations. - Memory footprints are similar for comparable bots; libraries that cache members or messages dominate usage in both.
Hosting a Discord bot on LuxuryNodes
LuxuryNodes Discord bot hosting runs Node.js, Python and Java bots from a control panel with a file manager, live console and automatic restarts, so the deployment steps above map directly onto it. Plans differ in memory and in how many bot instances you can run; start with the smallest that fits your bot's measured memory use and move up when that measurement says so.
Ready to host your own server?
Experience blazing-fast performance with LuxuryNodes. Built for gamers, loved by developers.
View Hosting Plans