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.
| Resource | Minimum | What I'd Pick |
|---|---|---|
| CPU | 1 vCPU | 2 vCPU (room for other stuff) |
| RAM | 1 GB | 2 GB |
| Storage | 10 GB SSD | 20 GB SSD |
| OS | Ubuntu 22.04+ | Ubuntu 24.04 LTS |
| Ports | 22 (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:
ssh root@YOUR_SERVER_IPIt'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:
# 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 - moltbotFrom here on, everything happens as the moltbot user.
2. Install Node.js
Moltbot needs Node.js 22 or later. NodeSource makes this easy:
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
node --version # Should show v22.xVersion 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
npx moltbot initFollow 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:
# 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 ~/.envWhy 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:
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
EOFNow start it up:
sudo systemctl daemon-reload
sudo systemctl enable moltbot # Start on boot
sudo systemctl start moltbot # Start right nowCheck the status:
sudo systemctl status moltbotIf 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:
sudo ufw allow OpenSSH # Otherwise you'll lock yourself out
sudo ufw enable # Turn on the firewall
sudo ufw status # Verify the rulesDon'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:
# 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:latestThe --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:
# systemd
sudo journalctl -u moltbot -f
# Docker
docker logs -f moltbotCommon issues:
ANTHROPIC_API_KEY not set— Your.envfile path is wrong, orEnvironmentFilehas a typoECONNREFUSED— Network issue. Check DNS resolution and firewall rulesPermission denied— File ownership problem. Fix withchown moltbot:moltbot- Keeps restarting — Usually an invalid API key. Check your Anthropic Console
Don't Have a VPS Yet?
Get started with these offers:
Next Steps
Your server is running, but there are a few more things you should set up:
- Security Configuration — Essential reading for VPS deployments
- Telegram Setup — Connect your bot to Telegram
- Memory System — Make your bot remember preferences
- Scheduled Tasks — Get daily briefings every morning