
Deploy MoltBot on VPS - Ubuntu Server Guide
Install MoltBot on VPS. Ubuntu deployment with systemd, nginx, and production best practices.
Deploy MoltBot on a VPS
Running MoltBot on a VPS gives you a 24/7 AI assistant accessible from anywhere. This guide covers deploying on Ubuntu Server with production-ready configuration.
Recommended VPS Specs
Minimum
- CPU: 1 vCPU
- RAM: 2 GB
- Storage: 20 GB SSD
- OS: Ubuntu 22.04 LTS
Recommended
- CPU: 2+ vCPU
- RAM: 4 GB
- Storage: 40 GB SSD
- OS: Ubuntu 22.04 LTS
For Local Models
- CPU: 4+ vCPU
- RAM: 16 GB+
- GPU: Optional NVIDIA GPU
Initial Server Setup
Connect to Your Server
ssh root@your-server-ipCreate a Non-Root User
adduser moltbot
usermod -aG sudo moltbot
su - moltbotUpdate System
sudo apt update && sudo apt upgrade -yInstall Essential Packages
sudo apt install -y curl git build-essentialInstalling Node.js
Using nvm (Recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20Verify Installation
node --version # Should be v20.x.x
npm --versionInstalling MoltBot
Method 1: npm
npm install -g moltbotMethod 2: From Source
git clone https://github.com/moltbot/moltbot.git
cd moltbot
npm install
npm run buildInitial Configuration
moltbot setupEnvironment Configuration
Create Environment File
mkdir -p ~/.moltbot
nano ~/.moltbot/.envAdd your configuration:
# AI Provider
ANTHROPIC_API_KEY=sk-ant-xxx
# Or use other providers
# OPENAI_API_KEY=sk-xxx
# GOOGLE_AI_API_KEY=xxx
# Messaging (optional)
TELEGRAM_BOT_TOKEN=xxx
DISCORD_BOT_TOKEN=xxx
# Production settings
NODE_ENV=production
LOG_LEVEL=infoSecure the File
chmod 600 ~/.moltbot/.envRunning with systemd
Create Service File
sudo nano /etc/systemd/system/moltbot.serviceAdd:
[Unit]
Description=MoltBot AI Assistant
After=network.target
[Service]
Type=simple
User=moltbot
WorkingDirectory=/home/moltbot
ExecStart=/home/moltbot/.nvm/versions/node/v20.10.0/bin/moltbot start
Restart=always
RestartSec=10
EnvironmentFile=/home/moltbot/.moltbot/.env
# Security hardening
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=read-only
ReadWritePaths=/home/moltbot/.moltbot
[Install]
WantedBy=multi-user.targetEnable and Start
sudo systemctl daemon-reload
sudo systemctl enable moltbot
sudo systemctl start moltbotCheck Status
sudo systemctl status moltbotView Logs
sudo journalctl -u moltbot -fFirewall Configuration
Using UFW
# Enable firewall
sudo ufw enable
# Allow SSH
sudo ufw allow ssh
# Allow HTTP/HTTPS (if using web interface)
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Check status
sudo ufw statusReverse Proxy with Nginx
If MoltBot has a web interface or webhook:
Install Nginx
sudo apt install -y nginxConfigure Site
sudo nano /etc/nginx/sites-available/moltbotAdd:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}Enable Site
sudo ln -s /etc/nginx/sites-available/moltbot /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxSSL with Let's Encrypt
Install Certbot
sudo apt install -y certbot python3-certbot-nginxGet Certificate
sudo certbot --nginx -d your-domain.comAuto-Renewal
sudo systemctl enable certbot.timerUsing Docker (Alternative)
Install Docker
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker moltbotDocker Compose Setup
Create docker-compose.yml:
version: '3.8'
services:
moltbot:
image: moltbot/moltbot:latest
container_name: moltbot
restart: unless-stopped
env_file:
- .env
volumes:
- ./data:/app/data
ports:
- "127.0.0.1:3000:3000"Start with Docker
docker compose up -dMonitoring
With PM2
npm install -g pm2
pm2 start moltbot --name moltbot
pm2 save
pm2 startupHealth Check Script
Create /home/moltbot/healthcheck.sh:
#!/bin/bash
if ! systemctl is-active --quiet moltbot; then
echo "MoltBot is down! Restarting..." | mail -s "MoltBot Alert" you@email.com
sudo systemctl restart moltbot
fiAdd to crontab:
crontab -e
# Add:
*/5 * * * * /home/moltbot/healthcheck.shBackup Strategy
Automated Backups
Create /home/moltbot/backup.sh:
#!/bin/bash
BACKUP_DIR="/home/moltbot/backups"
DATE=$(date +%Y%m%d)
mkdir -p $BACKUP_DIR
tar -czf $BACKUP_DIR/moltbot-$DATE.tar.gz /home/moltbot/.moltbot
# Keep only last 7 days
find $BACKUP_DIR -name "*.tar.gz" -mtime +7 -deleteSchedule daily backups:
crontab -e
# Add:
0 3 * * * /home/moltbot/backup.shOffsite Backup
# Install rclone
curl https://rclone.org/install.sh | sudo bash
# Configure (e.g., for S3)
rclone config
# Add to backup script
rclone sync $BACKUP_DIR remote:moltbot-backupsSecurity Hardening
SSH Key Only
# On local machine
ssh-copy-id moltbot@your-server-ip
# On server
sudo nano /etc/ssh/sshd_config
# Set: PasswordAuthentication no
sudo systemctl restart sshdFail2Ban
sudo apt install -y fail2ban
sudo systemctl enable fail2banAutomatic Updates
sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgradesUpdating MoltBot
npm Installation
npm update -g moltbot
sudo systemctl restart moltbotDocker Installation
docker compose pull
docker compose up -dTroubleshooting
Service Won't Start
# Check logs
sudo journalctl -u moltbot -n 100
# Check permissions
ls -la ~/.moltbot/Memory Issues
# Check memory
free -h
# Add swap if needed
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstabHigh CPU Usage
Limit MoltBot resources in config or use cgroups.
Your MoltBot is now running 24/7 on your VPS! Need help? Join our Discord community.
Categories
More Posts

MoltBot GitHub - Source Code, Installation & Contributing Guide
Official MoltBot GitHub repository. Clone, install from source, and contribute to the open source project. Complete guide to MoltBot GitHub.
ClawdBot is Now MoltBot - Migration Guide
ClawdBot has been rebranded to MoltBot. Learn how to migrate from ClawdBot to MoltBot seamlessly. All features remain the same.

MoltBot Skills: Extend Your AI with 50+ Integrations
Explore MoltBot's extensive skill system with 50+ built-in integrations. Learn how to use existing skills and create your own custom integrations.
Newsletter
Join the community
Subscribe to our newsletter for the latest news and updates