← All articles
Self-hostingDeployment

Deploy Paperclip on AWS EC2

AWS EC2 gives you full control over your Paperclip deployment — instance type, region, networking, and storage are all configurable. A t3.small or t3.medium instance handles Paperclip well, and you can scale up as your agent workloads grow.

Deploy on Railway instead →

Why AWS EC2 for Paperclip

EC2 makes sense if you're already in the AWS ecosystem — you get VPC isolation, IAM roles, CloudWatch monitoring, RDS for managed Postgres (optional), and the ability to run Paperclip alongside other AWS services. The tradeoff is complexity: there's more to configure compared to managed platforms. But if you're comfortable with AWS, it's a solid choice.

Prerequisites

  • AWS account with EC2 access
  • AWS CLI installed (aws configure with your credentials)
  • A domain name for SSL

Step 1: Launch an EC2 instance

In the EC2 console, click Launch Instance:

  • Name: paperclip
  • AMI: Ubuntu Server 22.04 LTS (HVM), SSD Volume Type
  • Instance Type: t3.small (2 vCPU / 2 GB RAM) — minimum. t3.medium (4 GB RAM) recommended for production.
  • Key Pair: Create or select an existing key pair
  • Network Settings:
    • VPC: default or your custom VPC
    • Auto-assign Public IP: Enable
    • Create a security group with these rules:
      • SSH (22) — your IP only
      • HTTP (80) — 0.0.0.0/0
      • HTTPS (443) — 0.0.0.0/0
  • Storage: 20 GB gp3 (general purpose SSD)
  • Click Launch Instance

Step 2: Assign an Elastic IP

Elastic IPs ensure your server's IP doesn't change on restart:

  1. Go to EC2 → Elastic IPs → Allocate Elastic IP Address
  2. After allocation, click Actions → Associate Elastic IP Address
  3. Select your Paperclip instance and associate

Step 3: Connect and configure

ssh -i your-key.pem ubuntu@YOUR_ELASTIC_IP

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git nginx ufw

Create a deploy user:

sudo adduser deploy
sudo usermod -aG sudo deploy
sudo rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy

Step 4: Install Node.js 20

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
node --version

Step 5: Install Paperclip

sudo npm install -g paperclipai

sudo mkdir -p /opt/paperclip/data
sudo chown -R deploy:deploy /opt/paperclip

Create /opt/paperclip/.env:

cat > /opt/paperclip/.env << 'EOF'
NODE_ENV=production
PAPERCLIP_DATA_DIR=/opt/paperclip/data
BETTER_AUTH_SECRET=REPLACE_WITH_RANDOM_SECRET
PAPERCLIP_LISTEN_PORT=3100
PAPERCLIP_LISTEN_HOST=127.0.0.1
EOF
chmod 600 /opt/paperclip/.env

Step 6: Systemd service

sudo tee /etc/systemd/system/paperclip.service << 'EOF'
[Unit]
Description=Paperclip AI
After=network.target

[Service]
Type=simple
User=deploy
WorkingDirectory=/opt/paperclip
EnvironmentFile=/opt/paperclip/.env
ExecStart=/usr/bin/npx paperclipai server start
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now paperclip

Step 7: nginx reverse proxy

sudo tee /etc/nginx/sites-available/paperclip << 'EOF'
server {
    listen 80;
    server_name paperclip.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:3100;
        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_read_timeout 300;
    }
}
EOF

sudo ln -s /etc/nginx/sites-available/paperclip /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Step 8: SSL with Certbot

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d paperclip.yourdomain.com

Alternatively, use AWS Certificate Manager (ACM) with an Application Load Balancer for managed SSL termination — better for production but adds cost and complexity.

Step 9: DNS

In Route 53 (or your DNS provider), create an A record:

paperclip.yourdomain.com → YOUR_ELASTIC_IP

Increasing EBS storage

If you need more disk space later:

  1. In EC2 console, select your instance → Storage → Volume ID
  2. Click Actions → Modify Volume and increase size
  3. On the server: sudo growpart /dev/xvda 1 && sudo resize2fs /dev/xvda1

Monitoring with CloudWatch

EC2 includes basic CloudWatch metrics (CPU, network, disk I/O). Enable detailed monitoring for 1-minute granularity:

aws ec2 monitor-instances --instance-ids YOUR_INSTANCE_ID

Backups with EBS snapshots

Create automated snapshots in the AWS Backup console, or manually:

aws ec2 create-snapshot \
  --volume-id YOUR_VOLUME_ID \
  --description "Paperclip backup $(date +%Y-%m-%d)"

Cost

  • t3.small (2 vCPU / 2 GB): ~$15/month on-demand, ~$7/month with 1-year Reserved
  • t3.medium (2 vCPU / 4 GB): ~$30/month on-demand, ~$14/month Reserved
  • gp3 EBS (20 GB): ~$1.60/month
  • Elastic IP (when in use): Free

Total for basic deployment: ~$15–30/month on-demand.

For much lower cost and zero server management, Railway gives you $20 free credit and deploys Paperclip in minutes.

Ready to deploy?

Affiliate disclosure: this link may earn us a commission at no extra cost to you.

This is an independent guide. Paperclip Hosting is not affiliated with the official Paperclip project. Guide steps are based on real deployments and are subject to change as the software evolves.