Docs
Everything you need to get a bot, app or website running on Hostrix.
Getting started
- Create an account. It's free and doesn't need a card.
- Click New server and choose Python, Node.js or Website.
- Your server starts with a working example. Press Start to see it run in the console.
- Replace the example with your own code in Files, then press Restart.
Python bots
Your main file is main.py unless you change it in Startup. List your packages in requirements.txt, one per line:
discord.py
Then read your token from the environment instead of pasting it into your code:
import os, discord intents = discord.Intents.default() intents.message_content = True bot = discord.Client(intents=intents) @bot.event async def on_ready(): print(f"Logged in as {bot.user}") bot.run(os.environ["DISCORD_TOKEN"])
Packages install the first time you press Start, and again whenever requirements.txt changes. Restarts after that are instant.
Node.js bots
Your main file is index.js. Add your packages to package.json:
{
"name": "my-bot",
"main": "index.js",
"dependencies": { "discord.js": "^14.16.0" }
}
const { Client, GatewayIntentBits } = require("discord.js"); const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.once("ready", () => console.log(`Logged in as ${client.user.tag}`)); client.login(process.env.DISCORD_TOKEN);
npm install runs every time you press Start.
Web apps
Flask, FastAPI, Express and other web servers must listen on the port in the PORT environment variable, on host 0.0.0.0:
# Flask app.run(host="0.0.0.0", port=int(os.environ["PORT"])) // Express app.listen(process.env.PORT, "0.0.0.0");
Your app's address is shown under the server name and on the Network tab.
Websites
Website servers serve your files as they are. Put an index.html in the top folder, add your CSS, JavaScript and images, then press Start to publish. Stop takes the site offline again. Files starting with a dot, like .env, are never served.
Uploading files
- Drag files onto the file list, or press Upload.
- For a whole project, zip it on your computer, upload the
.zip, then press Unzip. - Don't upload
node_modulesor virtual environments. They install themselves and only waste your disk space. - Click any file to edit it. Save with Ctrl+S, or ⌘S on a Mac.
Secrets and tokens
Never put your bot token in your code. Anyone who sees your files could take over your bot. Instead:
- Open your server and go to Startup.
- Under Environment variables, add the name
DISCORD_TOKENand paste your token as the value. - Press Restart. Your code reads it with
os.environ["DISCORD_TOKEN"]orprocess.env.DISCORD_TOKEN.
If a token ever leaks, reset it in the Discord Developer Portal and update the variable.
Limits and crashes
- Memory: if your app goes over its memory limit, it's stopped. Check the Memory meter on the Console tab.
- Disk: uploads and saves that would go over your disk limit are refused.
- Crashes: with auto-restart on (the default), a crashed app restarts after 5 seconds. If it crashes more than 3 times in 2 minutes, auto-restart pauses so you can fix the error.
Troubleshooting
- ModuleNotFoundError or Cannot find module
- The package isn't in
requirements.txtorpackage.json. Add it and restart. - KeyError: 'DISCORD_TOKEN'
- The variable isn't set. Add it under Startup, check the spelling matches exactly, and restart.
- Improper token has been passed
- The token is wrong or was reset. Copy a fresh one from the Discord Developer Portal.
- Privileged intents error
- Turn on the intents your bot uses (like Message Content) under Bot in the Discord Developer Portal.
- Killed: memory limit exceeded
- Your app used more memory than your plan allows. Reduce caching or upgrade your plan.