Skip to content
Minecraft Minecraft: Bedrock Edition Rust Counter-Strike 2 Palworld Valheim Satisfactory Enshrouded
Configure server Sign in
DE EN

Reliably Start a Discord Bot on a Server

An existing Discord bot runs reliably when the server uses the same runtime and dependencies as the project, starts the correct entry point, and receives the bot token as an environment variable. First check the files and startup instructions for the existing bot. Do not invent a new startup file or blindly install the latest version of every package.


An existing Discord bot runs reliably when the server uses the same runtime and dependencies as the project, starts the correct entry point, and receives the bot token as an environment variable. First check the files and startup instructions for the existing bot. Do not invent a new startup file or blindly install the latest version of every package.

1. Identify the Entry Point and Project Files

Work from a trusted, complete copy of the bot project. If you transfer the project files over SFTP, follow the guidance on secure file transfer; access and the target path depend on the hosting. First read its README and check the existing manifest and lock files: for Node.js, for example, package.json and package-lock.json; for Python, pyproject.toml or requirements.txt. Look for a startup script, the expected entry point, and runtime requirements. Names such as index.js or main.py are not automatically correct; use them only if the project actually uses them.

Run the startup command from the project directory that contains the configuration and dependencies. Node.js starts an existing program entry point with node; if the project defines a start script, use it. In Python, call the existing entry point with the exact interpreter in whose environment the packages are installed. The Node.js CLI documentation describes the program entry point; npm explains that npm start runs the start script defined by the project (npm scripts).

2. Set Up a Compatible Runtime and Dependencies

Compare the installed Node or Python version with the requirements of the project and the Discord library actually in use. Check them before starting, for example with node --version and npm --version, or with python3 --version; if you use an existing virtual environment, also check ./.venv/bin/python --version on Unix-like systems. A newer runtime is not automatically compatible; change it only when the project and library documentation supports that change.

For a Node project with an existing package-lock.json, npm ci restores the packages recorded in it. The command expects this lock file and stops if it conflicts with package.json. Run it in the project directory when dependencies need to be set up again; do not use it as a reason to update packages unexpectedly on a running server. npm describes npm ci.

For Python, a virtual environment keeps the bot's packages separate from other Python projects. Use an environment already available on the target system or set one up in the server copy according to the project instructions. Do not copy a local .venv to the server: Python environments are not designed to be moved. Create the environment at the target with the appropriate Python 3 interpreter, for example with python3 -m venv .venv if that command is available there. If the project provides a requirements.txt, install from it in that exact environment, for example with ./.venv/bin/python -m pip install -r requirements.txt on a Unix-like runtime. This keeps pip and the later startup on the same interpreter. Python explains virtual environments; pip documents installs from a requirements file.

3. Set the Configuration for the Running Process

The bot needs the token expected by the application. Set it as a secret environment variable using the name already used by the project, for example DISCORD_BOT_TOKEN (only the variable name is an example here). Do not put a real value in startup commands, source code, logs, or screenshots. Node.js provides process environment variables through process.env; Python provides them through os.environ. The variable must be set for the specific process that starts the bot. Node.js environment variables and Python os.environ.

If you change the token or other startup values, a new process must start with the current environment. A process that is already running does not automatically pick up a later change to its startup environment. Which startup or restart method is available depends on the hosting and its documentation. No AeonHost-specific process manager or restart feature is assumed here. If you cannot find a persistent runtime or a suitable startup command, check the hosting documentation before moving the bot.

4. Start the Bot and Check Its State

Use the startup method already specified by the project. In a Node project, this may be a defined start script such as npm start; otherwise, start the confirmed entry point with node <vorhandener-einstiegspunkt>. With Python, use the interpreter from the project environment, for example ./.venv/bin/python <vorhandener-einstiegspunkt>. Replace the placeholders with the actual path from the project. Do not start an arbitrary file name or append a token value to the command.

Check the process console output immediately after startup. A successful Gateway connection should appear in the framework as a logged-in or ready bot; the bot should then appear online in Discord. Test an existing feature in a suitable test channel and continue watching the logs until it is clear that the process stays active instead of exiting immediately. Discord describes the Gateway connection process and the Ready event in its Gateway documentation.

Do not accidentally start multiple copies of the same instance. If a process is already running, check its output and state before starting a second one. Duplicate instances can cause repeated responses or competing writes, unless the project is explicitly designed for them.

5. Narrow Down Common Startup Problems

  • Module or package is missing: Check that you are in the project directory and that the installation took place in the same interpreter or Node project that starts the bot. For Python, ./.venv/bin/python -m pip list shows the packages in that exact environment.
  • Token is rejected: Check that the expected variable name is set and that you restarted the process after changing it. Do not display the value in diagnostic output. If the token was exposed, follow the guide to secure and reset the bot token.
  • Gateway reports 4014: The application requests a privileged intent that is not enabled in the app settings or does not have the required approval. Compare the Portal switch with the configuration of the existing bot. Remove the intent if the feature does not need it. Discord describes this error in the Gateway intents documentation.
  • The bot is online, but the feature does not work: Check that the bot is on the right server, that its role and the channel have the required permissions, and that the feature uses the command type actually configured. Message commands may need additional intents; do not invent permissions—compare the specific library and Portal configuration.

Before a code or package update, secure the current state and test changes in a separate copy first. Change only one cause at a time and keep the original startup logs. The AeonHost documentation has more guides; for questions about supported runtime conditions, use Contact.

Did this guide help? We are happy to help personally.