Skip to content

VPS Deployment: Keep Moltbot Running 24/7

Let's be honest — running Moltbot on your laptop is fun for testing, but it's not practical. Close the lid, lose Wi-Fi for a second, and your bot goes silent.

If you're serious about using Moltbot, a VPS is the way to go. The good news? Moltbot is incredibly lightweight. The cheapest server you can find will probably work just fine.

What Kind of Server Do You Need?

Short answer: don't overspend. Moltbot barely uses any resources.

ResourceMinimumWhat I'd Pick
CPU1 vCPU2 vCPU (room for other stuff)
RAM1 GB2 GB
Storage10 GB SSD20 GB SSD
OSUbuntu 22.04+Ubuntu 24.04 LTS
Ports22 (SSH)+ 443 if using Webhooks

Recommended VPS Providers

These providers have been tested with Moltbot and work well:

Namecheap VPS — Starting at $3.88/mo. 1 CPU / 1GB RAM / 20GB SSD. Great value for a starter VPS. Annual billing at $46.56/year saves 20%.

Bluehost VPS — Starting at $4.99/mo. 1 vCPU / 2GB DDR5 RAM / 50GB NVMe storage with unmetered bandwidth. The NVMe drives make a noticeable difference in disk I/O.

DigitalOcean — New users get $200 in free credit over 60 days. Excellent documentation, one-click Docker setup, and a developer-friendly platform.

Let's Set It Up

Once you've bought a VPS, your provider will give you an IP address and root password. Open your terminal:

bash
ssh root@YOUR_SERVER_IP

It'll ask about the fingerprint on first connect — type yes.

1. Update the System + Create a User

Running services as root is a bad idea. Let's create a dedicated user:

bash
# Update everything first — fresh servers often have stale packages
apt update && apt upgrade -y

# Create a user called moltbot
adduser moltbot
usermod -aG sudo moltbot

# Switch to the new user
su - moltbot

From here on, everything happens as the moltbot user.

2. Install Node.js

Moltbot needs Node.js 22 or later. NodeSource makes this easy:

bash
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
node --version  # Should show v22.x

Version Matters

Node 20 might work, but the official recommendation is 22+. Don't cut corners here — version mismatches cause weird bugs that are painful to debug.

3. Install Moltbot

bash
npx moltbot init

Follow the prompts. It'll create config files under ~/.moltbot/.

4. Set Up Environment Variables

This is critical — never put API keys in config files. Use environment variables:

bash
# Create an .env file (systemd will read this)
cat > ~/.env << 'EOF'
ANTHROPIC_API_KEY=sk-ant-xxxxx
TELEGRAM_BOT_TOKEN=xxxxx
EOF

# Lock permissions — only your user can read it
chmod 600 ~/.env

Why not .bashrc? Because systemd services don't go through a shell login, so they'd never see .bashrc. The EnvironmentFile directive is the correct approach.

5. Create a systemd Service

This is the most important step — it makes Moltbot start on boot and automatically restart if it crashes:

bash
sudo tee /etc/systemd/system/moltbot.service > /dev/null << 'EOF'
[Unit]
Description=Moltbot AI Assistant
After=network.target

[Service]
Type=simple
User=moltbot
WorkingDirectory=/home/moltbot
ExecStart=/usr/bin/npx moltbot start
Restart=on-failure
RestartSec=5
EnvironmentFile=/home/moltbot/.env

[Install]
WantedBy=multi-user.target
EOF

Now start it up:

bash
sudo systemctl daemon-reload
sudo systemctl enable moltbot   # Start on boot
sudo systemctl start moltbot    # Start right now

Check the status:

bash
sudo systemctl status moltbot

If you see active (running), you're golden. If it says failed, check the logs below.

6. Firewall

Ubuntu comes with ufw. Only open what you need:

bash
sudo ufw allow OpenSSH       # Otherwise you'll lock yourself out
sudo ufw enable              # Turn on the firewall
sudo ufw status              # Verify the rules

Don't Expose Port 3000

Moltbot's gateway listens on port 3000 by default. This port must never be open to the public internet — anyone could talk to your bot and burn through your API credits.

See the Security guide for real-world horror stories.

Or Just Use Docker (Easier)

If you don't want to deal with Node.js versions and systemd configs, Docker makes it dead simple:

bash
# Install Docker
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker moltbot
# Log out and back in for the docker group to take effect
exit
su - moltbot

# Run it
docker run -d \
  --name moltbot \
  --restart unless-stopped \
  -v ~/.moltbot:/root/.moltbot \
  -e ANTHROPIC_API_KEY=sk-ant-xxxxx \
  -e TELEGRAM_BOT_TOKEN=xxxxx \
  ghcr.io/steipete/moltbot:latest

The --restart unless-stopped flag is Docker's equivalent of systemd's Restart=on-failure — it handles restarts for you.

Want Docker Compose instead? Check the Docker deployment guide for a complete compose.yaml.

Logs & Troubleshooting

When something goes wrong, logs are your best friend:

bash
# systemd
sudo journalctl -u moltbot -f

# Docker
docker logs -f moltbot

Common issues:

  • ANTHROPIC_API_KEY not set — Your .env file path is wrong, or EnvironmentFile has a typo
  • ECONNREFUSED — Network issue. Check DNS resolution and firewall rules
  • Permission denied — File ownership problem. Fix with chown moltbot:moltbot
  • Keeps restarting — Usually an invalid API key. Check your Anthropic Console

Next Steps

Your server is running, but there are a few more things you should set up:

Community tutorial site — not affiliated with official Moltbot