DigitalOcean is one of the most popular choices for hosting Moltbot, and for good reason. With droplets starting at just $6/month, you get a reliable, scalable platform with excellent documentation and a straightforward interface. In this guide, we'll walk through the entire process of deploying Moltbot on DigitalOcean from scratch.
Why DigitalOcean for Moltbot?
Before we dive into the technical steps, let's quickly cover why DigitalOcean is an excellent choice for hosting your Moltbot instance:
- Cost-effective: The $6/month droplet is sufficient for personal use and light automation
- Simple scaling: Need more power? Resize your droplet with a few clicks
- Built-in backups: Enable automatic weekly backups for just 20% extra
- Great uptime: DigitalOcean maintains 99.99% uptime SLA
- Excellent documentation: Extensive tutorials and community support
Prerequisites
Before starting, make sure you have:
- A DigitalOcean account (sign up with our link for $200 in credits)
- A domain name (optional but recommended for SSL)
- Your Anthropic API key (or OpenAI, depending on your setup)
- Basic familiarity with the command line
Step 1: Create Your Droplet
Log into your DigitalOcean dashboard and click "Create" → "Droplets". Here are the recommended settings:
- Region: Choose the closest to your location for lowest latency
- Image: Ubuntu 22.04 LTS (most compatible with Moltbot)
- Size: Basic, $6/month (1 vCPU, 1GB RAM, 25GB SSD)
- Authentication: SSH keys (more secure than password)
- Hostname: Something descriptive like "moltbot-prod"
Click "Create Droplet" and wait about 60 seconds for it to spin up. Copy the IP address once it's ready.
Step 2: Initial Server Setup
SSH into your new droplet:
ssh root@YOUR_DROPLET_IPFirst, update the system and create a non-root user for security:
apt update && apt upgrade -y
adduser moltbot
usermod -aG sudo moltbot
rsync --archive --chown=moltbot:moltbot ~/.ssh /home/moltbotNow log out and log back in as your new user:
ssh moltbot@YOUR_DROPLET_IPStep 3: Install Dependencies
Moltbot requires Node.js and a few other packages:
# Install Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Install additional dependencies
sudo apt install -y git nginx certbot python3-certbot-nginx
# Verify installation
node --version # Should show v20.x
npm --versionStep 4: Clone and Configure Moltbot
# Clone the repository
git clone https://github.com/open-claw/open-claw.git ~/moltbot
cd ~/moltbot
# Install dependencies
npm install
# Create environment file
cp .env.example .env
nano .envIn your .env file, configure at minimum:
ANTHROPIC_API_KEY=sk-ant-your-key-here
# Or for OpenAI:
# OPENAI_API_KEY=sk-your-key-here
PORT=3000
NODE_ENV=productionStep 5: Set Up Nginx as Reverse Proxy
Nginx will handle SSL and proxy requests to Moltbot. Create a new configuration:
sudo nano /etc/nginx/sites-available/moltbotAdd this configuration (replace YOUR_DOMAIN with your actual domain):
server {
listen 80;
server_name YOUR_DOMAIN;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}Enable the site and get SSL:
sudo ln -s /etc/nginx/sites-available/moltbot /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
# Get SSL certificate (follow the prompts)
sudo certbot --nginx -d YOUR_DOMAINStep 6: Create a Systemd Service
To keep Moltbot running and auto-restart on crashes:
sudo nano /etc/systemd/system/moltbot.serviceAdd this configuration:
[Unit]
Description=Moltbot AI Assistant
After=network.target
[Service]
Type=simple
User=moltbot
WorkingDirectory=/home/moltbot/moltbot
ExecStart=/usr/bin/npm start
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=moltbot
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.targetEnable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable moltbot
sudo systemctl start moltbot
# Check status
sudo systemctl status moltbotStep 7: Configure Firewall
Lock down your droplet to only allow necessary traffic:
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enableStep 8: Verify Your Installation
Open your browser and navigate to https://YOUR_DOMAIN. You should see the Moltbot interface. If everything is working, congratulations - you've successfully deployed Moltbot on DigitalOcean!
Next Steps: Security Hardening
Your Moltbot is now running, but there's more work to do. Default installations have several security vulnerabilities that need addressing:
- API keys need proper protection beyond .env files
- Rate limiting should be configured
- Prompt injection defenses should be enabled
- Access controls need to be set up
Common Issues and Troubleshooting
Port 3000 already in use
Check what's using the port with sudo lsof -i :3000 and kill the process or change the port in your .env file.
Nginx 502 Bad Gateway
This usually means Moltbot isn't running. Check the status with sudo systemctl status moltbot and view logs with sudo journalctl -u moltbot -f.
SSL Certificate Issues
Make sure your domain's DNS is properly pointed to your droplet's IP before running certbot.
Scaling Up
If you find the $6 droplet isn't enough (you're seeing slow responses or running out of memory), you can easily resize. Go to your droplet in the DigitalOcean dashboard, click "Resize", and select a larger plan. The $12/month option with 2GB RAM handles most medium-usage scenarios well.
Summary
Deploying Moltbot on DigitalOcean is straightforward once you know the steps. The key points are: create a properly sized droplet, set up a non-root user, install dependencies, configure Nginx for SSL, and create a systemd service for reliability.
For most users, the $6/month droplet is sufficient to get started. As your usage grows, DigitalOcean makes it easy to scale up without migration hassles.