How to Run AutoGPT on a VPS for 24/7 Autonomous Operation
Deploy AutoGPT on a VPS for round-the-clock operation. Covers VPS selection, systemd setup, tmux persistence, monitoring, and cost comparison across providers.
Get more content like this on Telegram!
Daily AI tips, notes & resources — free
Running AutoGPT on your laptop works fine for experiments. It does not work for anything you want to actually rely on — your laptop closes, sleeps, or loses internet, and the agent stops mid-task.
A VPS gives you a persistent environment that runs 24/7. No closed lids, no sleep modes, no interrupted tasks. For automation workflows, research agents, or scheduled tasks, this is the only viable setup.
This guide walks through everything: picking and provisioning a VPS, configuring AutoGPT, setting up systemd for automatic restarts, using tmux for session management, and monitoring the agent remotely.
Why a VPS and Not a Home Server or Cloud Function
A home server works but adds maintenance burden and depends on your home internet. Cloud functions (Lambda, Cloud Run) are stateless and time-limited — poor fits for a long-running agent process. A VPS gives you a persistent virtual machine with a stable IP, persistent storage, and full control over the environment.
For context on where persistent agents fit in the broader AI agent landscape, see AI agents and the future of work and deploy AI model to production.
VPS Provider Comparison
Here is an honest cost comparison for a setup suitable for running AutoGPT continuously:
| Provider | Plan | RAM | CPU | Storage | Monthly cost | Notes |
|---|---|---|---|---|---|---|
| DigitalOcean | Basic Droplet | 2GB | 1 vCPU | 50GB SSD | $12 | Excellent docs, reliable |
| Linode (Akamai) | Nanode 2GB | 2GB | 1 vCPU | 50GB SSD | $12 | Very stable, good network |
| Vultr | Cloud Compute | 2GB | 1 vCPU | 55GB SSD | $12 | Wide datacenter choice |
| Hetzner Cloud | CX22 | 4GB | 2 vCPU | 40GB SSD | $6 | Best value, EU-based |
| AWS EC2 | t3.small | 2GB | 2 vCPU | EBS | ~$17 | More complex, enterprise |
| Google Cloud | e2-small | 2GB | 0.5–2 vCPU | 20GB | ~$15 | Spot instances available |
Recommendation: Hetzner for budget-conscious deployment, DigitalOcean for ease of use and documentation. For US-based workloads requiring specific data residency, Linode or Vultr.
The $6 Hetzner CX22 comfortably runs a single AutoGPT agent with Redis memory. For multiple agents or Milvus, use the CX32 (8GB, $14/month).
Provisioning Your VPS
We will use Ubuntu 22.04 LTS for this guide. Most providers offer it directly in their control panel.
After creating the VPS:
# 1. SSH into your new server
ssh root@your-server-ip
# 2. Update the system
apt update && apt upgrade -y
# 3. Create a non-root user
adduser autogpt
usermod -aG sudo autogpt
# 4. Set up SSH key authentication
mkdir -p /home/autogpt/.ssh
cp ~/.ssh/authorized_keys /home/autogpt/.ssh/
chown -R autogpt:autogpt /home/autogpt/.ssh
chmod 700 /home/autogpt/.ssh
chmod 600 /home/autogpt/.ssh/authorized_keys
# 5. Switch to non-root user for the rest
su - autogpt
Installing Dependencies
# Install Python 3.11 and tools
sudo apt install -y python3.11 python3.11-venv python3-pip git tmux
# Verify
python3.11 --version
# Install Docker (for Redis)
curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker autogpt
# Log out and back in for Docker group to take effect
exit
ssh autogpt@your-server-ip
Installing and Configuring AutoGPT
# Clone AutoGPT
cd /home/autogpt
git clone https://github.com/Significant-Gravitas/AutoGPT.git
cd AutoGPT
# Create virtual environment
python3.11 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Set up configuration
cp .env.template .env
nano .env
Configure your .env file for a server environment:
# .env for VPS deployment
OPENAI_API_KEY=sk-proj-your-key-here
OPENAI_API_BUDGET=20.0
SMART_LLM=gpt-4-turbo
FAST_LLM=gpt-3.5-turbo
TEMPERATURE=0
# Redis for persistent memory
MEMORY_BACKEND=redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your_redis_password
# Security (essential on a server)
RESTRICT_TO_WORKSPACE=True
EXECUTE_LOCAL_COMMANDS=False
BROWSE_CHUNK_MAX_LENGTH=5000
# Server-appropriate logging
LOG_LEVEL=INFO
PLAIN_OUTPUT=True
Setting Up Redis with Docker
# Start Redis with password and persistence
docker run -d \
--name autogpt-redis \
--restart unless-stopped \
-p 127.0.0.1:6379:6379 \
-v /home/autogpt/redis-data:/data \
redis/redis-stack:latest \
--requirepass your_redis_password \
--appendonly yes \
--appendfsync everysec
# Verify Redis is running
docker exec autogpt-redis redis-cli -a your_redis_password ping
# Should print: PONG
Note the 127.0.0.1:6379 binding — this exposes Redis only to the localhost, preventing external access. Never expose Redis to the public internet without authentication and firewall rules.
Running AutoGPT in tmux
For interactive use or development, tmux is the simplest approach. It keeps the session alive after you disconnect:
# Create a new tmux session
tmux new-session -s autogpt
# Inside tmux, activate the venv and start AutoGPT
source /home/autogpt/AutoGPT/venv/bin/activate
cd /home/autogpt/AutoGPT
python -m autogpt \
--ai-name "ResearchBot" \
--ai-role "An autonomous research assistant" \
--ai-goal "Research the latest developments in quantum computing" \
--ai-goal "Summarize findings in a report file" \
--ai-goal "Save the report to workspace/quantum_report.md" \
--continuous \
--continuous-limit 50
# Detach from the session: Ctrl+B then D
# Reattach later: tmux attach -t autogpt
Useful tmux commands for managing your agent:
# List active sessions
tmux ls
# Reattach to a session
tmux attach -t autogpt
# Kill a session
tmux kill-session -t autogpt
# Split pane (for monitoring logs alongside agent)
# Inside tmux: Ctrl+B then %
Setting Up systemd for Automatic Restarts
For a truly autonomous setup, systemd ensures AutoGPT restarts automatically if it crashes or if the server reboots:
# Create the service file
sudo nano /etc/systemd/system/autogpt.service
[Unit]
Description=AutoGPT Autonomous Agent
After=network.target docker.service
Wants=docker.service
[Service]
Type=simple
User=autogpt
WorkingDirectory=/home/autogpt/AutoGPT
Environment="PATH=/home/autogpt/AutoGPT/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ExecStart=/home/autogpt/AutoGPT/venv/bin/python -m autogpt \
--ai-name "ResearchBot" \
--ai-role "Autonomous research assistant" \
--ai-goal "Monitor RSS feeds for AI research papers" \
--ai-goal "Summarize new papers daily" \
--continuous \
--continuous-limit 100
Restart=on-failure
RestartSec=30
StandardOutput=append:/home/autogpt/logs/autogpt.log
StandardError=append:/home/autogpt/logs/autogpt-error.log
[Install]
WantedBy=multi-user.target
# Create log directory
mkdir -p /home/autogpt/logs
# Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable autogpt
sudo systemctl start autogpt
# Check status
sudo systemctl status autogpt
# View logs
sudo journalctl -u autogpt -f
# Or
tail -f /home/autogpt/logs/autogpt.log
Monitoring Your Agent Remotely
Without monitoring, you will not know if the agent got stuck, hit its budget, or completed successfully. Here is a minimal monitoring setup:
# Create a simple monitoring script
nano /home/autogpt/scripts/monitor.sh
#!/bin/bash
# monitor.sh - Check AutoGPT health and send alerts
LOG_FILE="/home/autogpt/logs/autogpt.log"
ALERT_EMAIL="your@email.com"
MAX_LOG_AGE_MINUTES=30
# Check if service is running
if ! systemctl is-active --quiet autogpt; then
echo "ALERT: AutoGPT service is not running" | \
mail -s "AutoGPT Down Alert" "$ALERT_EMAIL"
exit 1
fi
# Check if log file is being updated (agent is active)
LOG_AGE=$(( ($(date +%s) - $(stat -c %Y "$LOG_FILE")) / 60 ))
if [ "$LOG_AGE" -gt "$MAX_LOG_AGE_MINUTES" ]; then
echo "ALERT: AutoGPT log not updated for ${LOG_AGE} minutes (possible hang)" | \
mail -s "AutoGPT Stalled Alert" "$ALERT_EMAIL"
fi
# Check Redis is responding
if ! docker exec autogpt-redis redis-cli -a your_redis_password ping > /dev/null 2>&1; then
echo "ALERT: Redis is not responding" | \
mail -s "Redis Down Alert" "$ALERT_EMAIL"
fi
echo "AutoGPT health check: OK (log age: ${LOG_AGE} minutes)"
chmod +x /home/autogpt/scripts/monitor.sh
# Run every 15 minutes via cron
crontab -e
# Add:
# */15 * * * * /home/autogpt/scripts/monitor.sh >> /home/autogpt/logs/monitor.log 2>&1
For email alerts to work, install mailutils and configure an SMTP server, or use a webhook to Slack or Discord instead:
# Slack webhook alternative
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"AutoGPT alert: service is down"}' \
YOUR_SLACK_WEBHOOK_URL
Firewall Configuration
Lock down the server to prevent unauthorized access:
# Install and configure UFW
sudo apt install ufw
# Default deny incoming, allow outgoing
sudo ufw default deny incoming
sudo ufw default allow outgoing
# Allow SSH
sudo ufw allow ssh
# Allow nothing else (Redis should NOT be publicly accessible)
sudo ufw enable
# Verify
sudo ufw status
Managing API Costs on a Persistent Server
A 24/7 agent left running without cost controls will generate bills. Key protections:
# .env cost controls
OPENAI_API_BUDGET=20.0 # Daily/task budget
BROWSE_CHUNK_MAX_LENGTH=4000 # Reduce per-browse token usage
Additionally, use OpenAI's usage dashboard to set hard monthly limits. Autonomous agents on servers should always have a secondary cost ceiling at the provider level, not just in the application.
For AutoGPT configuration details beyond what is covered here, see AutoGPT environment variables configuration.
For how to write goals that make the agent's work more predictable and less likely to spiral, see AutoGPT prompt strategies for goal decomposition.
Deploying Updates
When the AutoGPT codebase updates or you change your configuration:
# Pull latest changes
cd /home/autogpt/AutoGPT
git pull origin master
# Reinstall dependencies if requirements changed
source venv/bin/activate
pip install -r requirements.txt
# Restart the service
sudo systemctl restart autogpt
# Verify it started cleanly
sudo systemctl status autogpt
tail -n 20 /home/autogpt/logs/autogpt.log
A fully configured AutoGPT VPS deployment gives you a reliable autonomous agent platform for roughly $6–12 per month in server costs, plus your OpenAI API usage. That is a reasonable foundation for automation workflows that would otherwise require constant manual attention.
Frequently Asked Questions
How much RAM does AutoGPT need on a VPS? AutoGPT itself uses about 200–400MB of RAM. If you add Redis for memory, add another 100–300MB. A 2GB RAM VPS is comfortable for a single agent. For multiple concurrent agents or Milvus as the memory backend, use 4GB or more.
Can I run multiple AutoGPT agents on the same VPS? Yes. Each AutoGPT instance is a separate Python process. Run them in separate tmux windows or as separate systemd services. The main constraint is API rate limits — multiple agents sharing the same OpenAI API key will hit rate limits faster.
What happens if the VPS restarts while AutoGPT is running? With a systemd service configured with Restart=always, AutoGPT will restart automatically after the VPS comes back online. If you use Redis for memory with persistence enabled, the agent's memory is preserved. Task state depends on whether AutoGPT had checkpointed progress.
Frequently Asked Questions
AiTechWorlds Team
✓ Verified WriterThe AiTechWorlds team is passionate about AI, technology, and education. We create high-quality, research-backed content to help you learn, grow, and succeed in the modern digital world.
Related Articles
10 AutoGPT Command Line Arguments (Continuous Mode, Speak)
Complete reference for AutoGPT's 10 most powerful CLI arguments. Master continuous mode, headless operation, and CI/CD integration for automated agent workflows.
10 AutoGPT Configuration Tweaks for Better Performance
10 proven AutoGPT configuration tweaks to improve speed, cut costs, and boost task success. Model selection, temperature, token limits, and workspace settings.
Build a Content Research Agent with AutoGPT (Trends, Outlines)
Build an AutoGPT content research agent that finds trending topics, analyzes SERPs, and generates SEO-ready outlines automatically — full workflow inside.
Build a Data Analysis Agent with AutoGPT (CSV, SQL, Plots)
Build a data analysis agent using AutoGPT that reads CSVs, queries SQL databases, and generates plots automatically. Full code with pandas and matplotlib.