Deploy your Discord bot
From code on your machine to a bot running 24/7 on our infra, with auto-restart on crashes.
Before you start
- Your bot code on your local machine — Node.js, Python, or any language with a runtime we support
- A
package.json(Node) orrequirements.txt(Python) listing your dependencies - Your bot token (from the Discord Developer Portal)
Step 1 — Open your panel
From your dashboard, click Open Panel next to your bot service. You'll land in the Pterodactyl panel with a file manager, console, and startup settings.
Step 2 — Upload your code
Three ways to get your files onto the server:
Panel upload (small bots)
- Go to the Files tab.
- Zip your project folder locally (exclude
node_modules,.git, and any secrets). - Upload the zip, then right-click → Unarchive.
SFTP (recommended for larger bots)
Follow the SFTP guide to connect, then drag your whole project folder into /home/container.
Git clone (Pro plans)
Open the panel console and run:
git clone https://github.com/yourname/yourbot.git .
# The . at the end clones into the current folderStep 3 — Install dependencies
From the panel console:
Node.js
npm install
# or if you use pnpm:
pnpm install
# or yarn:
yarn installPython
pip install -r requirements.txtStep 4 — Set environment variables
Never hardcode your bot token in the source. Use environment variables instead. In the panel, go to the Startup tab.
Add variables like:
DISCORD_TOKEN— your bot tokenDATABASE_URL— if you have oneOWNER_ID— your Discord user ID, if your code checks it
In your code, read them with process.env.DISCORD_TOKEN (Node) or os.environ["DISCORD_TOKEN"] (Python).
Step 5 — Set the startup command
Still in the Startup tab, look for the Startup Command field. Set it based on your language:
Node.js
node index.jsor whatever your entry file is — bot.js, src/index.js, etc.
Python
python main.pyTypeScript (via tsx)
npx tsx src/index.tsStep 6 — Start and watch the console
Click Start. Watch the console output. You should see your bot's normal startup log — something like:
Ready! Logged in as MyBot#1234
Serving 5 guildsIf you see errors, they're usually:
- Missing token — env var name doesn't match what the code expects
- Cannot find module — dependencies weren't installed, run
npm installagain - EADDRINUSE — the port is in use, change it or restart
- Out of memory — upgrade your plan, or fix the memory leak
Step 7 — Auto-restart (already on)
You don't need to do anything here. If your bot crashes, the panel detects the process exit and restarts it automatically. You'll see a [Server] Process exited, restarting... line in the console.
Updating your bot later
To deploy new code:
- Stop the server from the console (
stopfor Node, Ctrl+C for Python). - Upload the changed files via SFTP or panel.
- Run
npm installagain if package.json changed. - Start the server.
If you use Git: git pull instead of manual uploads.
Using the MySQL database
Your plan includes MySQL. In the panel, go to the Databases tab, click New Database, and note the credentials.
Connection string example for Node.js:
import mysql from "mysql2/promise";
const db = await mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
});Store the DB values as env vars in Startup tab (same as your bot token) so you can rotate them without code changes.
