Self-Host Activepieces with Docker Compose and Nginx

by Fahim Mahmud Chisti

To self-host Activepieces, you run its app and worker containers with PostgreSQL and Redis using Docker Compose, then put Nginx with a Let’s Encrypt certificate in front. At the end you will have your own Activepieces instance on your domain, with no per-task billing.

Quick answer: Create /opt/activepieces on a VPS with a docker-compose.yml (app, worker, PostgreSQL, Redis) and a .env file of generated secrets, run docker compose up -d, then proxy port 8080 through Nginx and add SSL with Certbot.

  1. Point a subdomain such as automation.yourdomain.com at the server.
  2. Create the compose file and the .env file with keys from openssl rand.
  3. Start the stack and check that every container is running.
  4. Add an Nginx server block, then run Certbot for HTTPS.
  5. Open the domain, create the admin account and run a test flow.
In this guide
  1. Why Self-Host Activepieces
  2. Before You Start
  3. How the Stack Fits Together
  4. Step 1: Write the Docker Compose File
  5. Step 2: Create the .env File
  6. Step 3: Start the Stack and Check the Containers
  7. Step 4: Put Nginx and Let’s Encrypt in Front
  8. Step 5: Test Your First Flow
  9. If It Still Doesn’t Work
  10. Frequently Asked Questions
  11. Next Steps
Self-hosted Activepieces running on Docker Compose in a server terminal

Why Self-Host Activepieces

Zapier and Make bill by the task or operation. A workflow that loops through 100 database rows every hour adds up to thousands of billable steps a day, far beyond a typical free tier. On your own server, the limit is your hardware rather than a monthly quota.

Your API keys and customer data also stay on a server you control. Activepieces is an open-source automation engine with a visual flow builder and code steps, and it fits alongside the other self-hosted tools for developers. If you are still deciding on a platform, the Zapier vs Make vs n8n comparison covers the hosted options.

Before You Start

  • Server: Activepieces’ documentation asks for at least 2 vCPUs and 4GB of RAM. A VPS of that size running a current Ubuntu LTS release works.
  • Access: SSH access with sudo. Every command in this guide runs on the server over SSH.
  • Docker: a current Docker Engine release with the Docker Compose V2 plugin. If you need to install it, see the official Docker Compose documentation.
  • A domain name: an A record for your subdomain pointing at the server’s public IP address, and ports 80 and 443 open, so Certbot can issue the certificate.
  • Time: about 45 minutes.

Keep all files for this app in one folder. This guide uses /opt/activepieces; create it and move into it:

mkdir -p /opt/activepieces && cd /opt/activepieces

How the Stack Fits Together

Activepieces can run with an embedded database for a quick test, but for anything you rely on you want the full stack of four containers:

  • Activepieces app: Serves the UI and the API.
  • Activepieces worker: Runs your flows.
  • PostgreSQL: Stores your users, flows, history, and credentials.
  • Redis: Manages the background job queue and coordinates workers.

The layout is similar to how you would self-host n8n with PostgreSQL. Because jobs wait in the Redis queue, a busy UI does not stop flows from being picked up by the worker.

Step 1: Write the Docker Compose File

Open a new docker-compose.yml in the project folder:

nano docker-compose.yml

Paste the following config. It follows the official docker-compose.yml in the Activepieces repository (version 0.94.0 at the time of writing; check the releases page for the current tag), with healthchecks added, the app port bound to localhost, and a single worker instead of the five replicas the official file starts. All settings and secrets come from the .env file you create in the next step.

services:
  app:
    image: ghcr.io/activepieces/activepieces:0.94.0
    container_name: activepieces_app
    restart: unless-stopped
    ports:
      - "127.0.0.1:8080:80"
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    env_file: .env
    environment:
      - AP_CONTAINER_TYPE=APP
    volumes:
      - ./cache:/usr/src/app/cache
  worker:
    image: ghcr.io/activepieces/activepieces:0.94.0
    restart: unless-stopped
    depends_on:
      - app
    env_file: .env
    environment:
      - AP_CONTAINER_TYPE=WORKER
    # A stopping worker finishes its running flows first
    stop_grace_period: 705s
    deploy:
      replicas: 1
    volumes:
      - ./cache:/usr/src/app/cache
  postgres:
    image: pgvector/pgvector:0.8.0-pg14
    container_name: activepieces_postgres
    restart: unless-stopped
    environment:
      - POSTGRES_DB=${AP_POSTGRES_DATABASE}
      - POSTGRES_USER=${AP_POSTGRES_USERNAME}
      - POSTGRES_PASSWORD=${AP_POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
      interval: 5s
      timeout: 5s
      retries: 5
  redis:
    image: redis:7.0.7
    container_name: activepieces_redis
    restart: unless-stopped
    volumes:
      - redis_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 5
volumes:
  postgres_data:
  redis_data:

Save the file (in nano: Ctrl+O, Enter, Ctrl+X). The app port is bound to 127.0.0.1:8080:80, which keeps it closed to the public internet. Nginx will forward external traffic to it and handle SSL.

Step 2: Create the .env File

Keep passwords out of the compose file. The .env file holds every secret and setting in one place.

First, generate the secrets. The encryption key must be exactly 32 hexadecimal characters (16 bytes); the other values are longer:

openssl rand -hex 16   # AP_ENCRYPTION_KEY
openssl rand -hex 32   # AP_JWT_SECRET
openssl rand -hex 32   # AP_POSTGRES_PASSWORD
openssl rand -hex 64   # AP_API_KEY

Each command prints one random string. Copy them somewhere safe, then create your environment file:

nano .env

Add the following variables (they mirror the .env.example file in the Activepieces repository), replacing the placeholders with your generated values and your domain:

# Application Settings
AP_ENVIRONMENT=prod
AP_ENGINE_EXECUTABLE_PATH=dist/packages/engine/main.js
AP_FRONTEND_URL=https://automation.yourdomain.com
AP_EXECUTION_MODE=UNSANDBOXED
AP_FLOW_TIMEOUT_SECONDS=600
AP_WEBHOOK_TIMEOUT_SECONDS=30
AP_TRIGGER_DEFAULT_POLL_INTERVAL=5
AP_TELEMETRY_ENABLED=true
AP_TEMPLATES_SOURCE_URL="https://cloud.activepieces.com/api/v1/flow-templates"
# Security Keys
AP_ENCRYPTION_KEY=your_generated_16_byte_hex_key_here
AP_JWT_SECRET=your_generated_jwt_secret_here
AP_API_KEY=your_generated_api_key_here
# Database Configuration
AP_POSTGRES_DATABASE=activepieces
AP_POSTGRES_HOST=postgres
AP_POSTGRES_PORT=5432
AP_POSTGRES_USERNAME=ap_admin
AP_POSTGRES_PASSWORD=your_super_secure_db_password_here
# Redis
AP_REDIS_HOST=redis
AP_REDIS_PORT=6379

Check these points before you save:

  • AP_FRONTEND_URL must match your domain exactly. Activepieces uses it to build webhook URLs and to handle OAuth redirects when you connect external apps.
  • The database user variable is AP_POSTGRES_USERNAME, not AP_POSTGRES_USER.
  • AP_TELEMETRY_ENABLED=true sends usage telemetry to Activepieces; set it to false if you prefer not to.
  • Keep a backup of this file. Without AP_ENCRYPTION_KEY, the connections you save in Activepieces cannot be decrypted.

Step 3: Start the Stack and Check the Containers

Start everything in the background:

docker compose up -d

Docker pulls the images and starts the containers. Give it a minute, then check their status:

docker compose ps

If it worked, the postgres and redis containers show running (healthy) and the app and worker show running. If the app container keeps restarting, check its logs:

docker compose logs -f app

A common cause on first boot is the app starting before PostgreSQL has finished initializing: a plain depends_on only waits for the database container to start, not for the database to accept connections. That is why the compose file above adds healthcheck blocks to PostgreSQL and Redis and makes the app wait for service_healthy. The other usual suspect is a mistake in .env, such as a mismatched database password or an encryption key that is not 32 characters long.

Step 4: Put Nginx and Let’s Encrypt in Front

With the app running locally on port 8080, expose it to the web through Nginx as a reverse proxy, with a free Let’s Encrypt certificate.

First, install Nginx:

sudo apt update && sudo apt install -y nginx

Create a new server block configuration for Activepieces:

sudo nano /etc/nginx/sites-available/activepieces

Paste the following config, replacing automation.yourdomain.com with your domain:

server {
  listen 80;
  server_name automation.yourdomain.com;
  location / {
    proxy_pass http://127.0.0.1:8080;
    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;
  }
}

Don’t skip the Upgrade and Connection headers. Activepieces uses WebSockets to stream live execution logs to your browser while you debug, and without these headers the logs fail to load.

Enable the configuration, test it and restart Nginx:

sudo ln -s /etc/nginx/sites-available/activepieces /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

nginx -t should report that the syntax is ok and the test is successful. If it shows an error, fix the line it names before you restart.

Now get an SSL certificate with Certbot. Install Certbot and its Nginx plugin:

sudo apt install -y certbot python3-certbot-nginx

Run Certbot to request the certificate. It updates your Nginx config to redirect HTTP to HTTPS:

sudo certbot --nginx -d automation.yourdomain.com

Follow the prompts. When Certbot reports that the certificate was deployed, open your domain in the browser. You should see the Activepieces setup screen asking you to create your admin account; create it straight away so nobody else can claim the instance.

Step 5: Test Your First Flow

After you register, you land on the dashboard. Run a quick test to make sure the worker is processing jobs:

  1. Click New Flow in the top right corner.
  2. Select the Webhook trigger and copy the generated webhook URL.
  3. Add a new step, choose the HTTP piece, and configure it to send a test request.
  4. Click Test Flow.

The run is queued in Redis and executed by the worker container. If it worked, the test completes and shows the output of each step. If the test never finishes, check docker compose logs worker.

If It Still Doesn’t Work

  • 502 Bad Gateway from Nginx: the app container is not running or is still starting. Check docker compose ps and the app logs, and confirm the compose file still maps 127.0.0.1:8080.
  • Certbot fails to get a certificate: the A record does not point at this server yet, or port 80 is blocked by a firewall. Check DNS, open ports 80 and 443, and run Certbot again. For renewal problems later, see fixing Certbot auto-renewal failures on Nginx.
  • Webhook URLs or OAuth redirects use the wrong address: AP_FRONTEND_URL does not match the domain you browse to. Correct it in .env and run docker compose up -d again.
  • Live logs never load in the flow editor: the WebSocket headers are missing from the Nginx config. Add them, run sudo nginx -t, and restart Nginx.
  • The app crashes with a database or encryption error: re-check the AP_POSTGRES_* values against the postgres service and confirm the encryption key is 32 characters.

Frequently Asked Questions

How much RAM does Activepieces actually use?

It depends on how many flows run at once, so measure it on your own server with docker stats, which shows live memory use per container. Activepieces’ documentation lists 2 vCPUs and 4GB of RAM as the minimum, so plan for at least that before you add more workers.

How do I update Activepieces to the latest version?

Read the release notes for breaking changes and back up the database first. Then open docker-compose.yml in your project directory, update the version tag on both the app and worker images, and run:

docker compose pull
docker compose up -d

Activepieces runs its database migrations automatically on startup.

Can I use an external PostgreSQL database?

Yes. If you use a managed database service, delete the postgres block (and its depends_on entry) from docker-compose.yml. Then update the AP_POSTGRES_* variables in .env to point to your external instance, and run docker compose up -d.

How do I back up my Activepieces data?

Back up the Postgres database and your .env file. Run this from /opt/activepieces to dump the database from the running container:

docker compose exec -T postgres pg_dump -U ap_admin activepieces > backup.sql

Keep backup.sql and your .env file stored safely off the server. The dump alone is not enough, because saved connections need the encryption key from .env.

Next Steps

Schedule the backup command with cron, and practise restoring it once so you know it works. Then build your first real flow, starting with a webhook trigger from a tool you already use. To compare Activepieces with a similar self-hosted engine, see the guide to running n8n with PostgreSQL.

all_in_one_marketing_tool