Overview
Heroku is a cloud platform that supports Node.js applications with git-based deployments. Yato includes aProcfile for Heroku compatibility.
Prerequisites
- Heroku account (sign up)
- Heroku CLI installed (download)
- Git installed
- Discord bot token
- MongoDB connection string (use MongoDB Atlas free tier)
Deployment steps
Create Heroku application
Create a new Heroku app with a unique name:Or let Heroku generate a random name:
Configure environment variables
Set your environment variables using Heroku config vars:
You can also set config vars through the Heroku Dashboard under Settings > Config Vars.
Understanding the Procfile
The includedProcfile defines how Heroku runs the bot:
Procfile
- worker: Dyno type (background worker, not web server)
- node .: Runs
node src/index.jsbased onpackage.jsonmain field
Worker dynos don’t require a port binding like web dynos, making them ideal for Discord bots.
Managing your Heroku deployment
View logs
Restart the bot
Update environment variables
Check dyno status
Setting up MongoDB Atlas
Since Heroku doesn’t provide free database hosting:Create MongoDB Atlas account
Sign up at MongoDB Atlas
Configure network access
In Network Access, add
0.0.0.0/0 to allow connections from anywhere (Heroku IPs are dynamic)Updating your bot
When you make changes to the code:Troubleshooting
Bot is not coming online
MongoDB connection fails
- Verify connection string format
- Ensure Network Access allows
0.0.0.0/0 - Check database user credentials
- Test connection locally first
Commands not registering
- Slash commands may take up to 1 hour to register globally
- Use
GUILD_IDenvironment variable for instant registration in a test server - Check bot permissions in Discord Developer Portal
Dyno exceeds memory quota
Canvas operations can be memory-intensive:- Upgrade to Eco Dyno or higher ($5+/month)
- Optimize Canvas usage in welcome cards
- Clear caches more frequently
Cost optimization
| Plan | Cost | Dyno Hours | Best For |
|---|---|---|---|
| Eco Dyno | $5/month | 1000 hours | Single bot, small servers |
| Basic Dyno | $7/month | Always-on | Production use |
| Standard Dynos | $25+/month | Always-on + performance | High-traffic bots |
Alternative deployment
If Heroku doesn’t meet your needs:- Docker deployment for any VPS
- Railway (similar to Heroku with free tier)
- DigitalOcean App Platform