analytics · Deploy guide
Self-host Plausible Analytics
Simple, privacy-friendly Google Analytics alternative. Here's how to run Plausible Analytics on your own infrastructure — no marketing puffery, honest pitfalls, one recommended stack.
Every guide on SwapToSaaS runs on servers we actually pay for. Plausible Analytics's footprint fits comfortably on this class of instance. Different provider preference? The steps below work anywhere Docker runs.
Provision a server →Before you start
Plausible is a cookieless, privacy-first analytics tool — one dashboard, one 1 KB script tag, no consent banner needed. This guide deploys the fully open-source Community Edition (v2.1+) with Postgres and ClickHouse behind Caddy for TLS. Roughly one hour end-to-end.
You'll need:
- A domain (e.g.
analytics.yourcompany.com) with DNS pointing to your server. - An SMTP account (Postmark, Resend, SES) or Postmark free tier for verification emails.
Step 1 · Provision the server (5 min)
ssh root@YOUR_SERVER_IP
adduser deploy && usermod -aG sudo deploy
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
systemctl restart ssh Step 2 · DNS (5 min)
analytics.yourcompany.com → YOUR_SERVER_IP Step 3 · Install Docker (5 min)
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update && sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER && newgrp docker Step 4 · Clone the community setup (10 min)
cd ~
git clone https://github.com/plausible/community-edition.git plausible
cd plausible
mkdir -p caddy_data caddy_config Edit plausible-conf.env:
BASE_URL=https://analytics.yourcompany.com
SECRET_KEY_BASE=RANDOM_64_CHAR_STRING
TOTP_VAULT_KEY=BASE64_URL_SAFE_32_BYTES
[email protected]
SMTP_HOST_ADDR=smtp.postmarkapp.com
SMTP_HOST_PORT=587
SMTP_USER_NAME=YOUR_POSTMARK_TOKEN
SMTP_USER_PWD=YOUR_POSTMARK_TOKEN
DISABLE_REGISTRATION=invite_only Generate secrets:
openssl rand -base64 48 # SECRET_KEY_BASE
openssl rand -base64 32 | tr '+/' '-_' # TOTP_VAULT_KEY Step 5 · Add Caddy for TLS (10 min)
The default community-edition compose exposes Plausible on port 8000. Add a Caddy service for automatic HTTPS. Create compose.override.yml:
services:
caddy:
image: caddy:2-alpine
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- ./caddy_data:/data
- ./caddy_config:/config
depends_on:
- plausible
plausible:
ports: [] ~/plausible/Caddyfile:
analytics.yourcompany.com {
reverse_proxy plausible:8000
} Step 6 · Bring it up (10 min)
cd ~/plausible
docker compose up -d
docker compose logs -f plausible First boot runs database migrations. ClickHouse takes a minute to initialize. Wait for Running PlausibleWeb.Endpoint with cowboy 2.x. Ctrl+C to detach.
Open https://analytics.yourcompany.com. Register the first user — that user becomes the workspace owner.
Step 7 · Add your first site (5 min)
Log in → Add a site → paste the domain you want to track. Copy the tracking snippet:
<script defer data-domain="yourdomain.com" src="https://analytics.yourcompany.com/js/script.js"></script> Drop it in your site's <head>. Reload the page. The dashboard should show 1 pageview within 30 seconds.
Firewall and backups (10 min)
sudo ufw allow 22/tcp && sudo ufw allow 80/tcp && sudo ufw allow 443/tcp && sudo ufw --force enable Nightly backup — both Postgres and ClickHouse:
sudo tee /etc/cron.daily/plausible-backup > /dev/null <<'EOF'
#!/bin/bash
set -e
BACKUP_DIR=/home/deploy/backups
mkdir -p "$BACKUP_DIR"
cd /home/deploy/plausible
docker compose exec -T plausible_db pg_dump -U postgres plausible_db | gzip > "$BACKUP_DIR/plausible-pg-$(date +%Y%m%d).sql.gz"
docker compose exec -T plausible_events_db clickhouse-client --query "BACKUP DATABASE plausible_events_db TO Disk('backups', 'plausible-$(date +%Y%m%d).zip')" || true
find "$BACKUP_DIR" -name "plausible-*" -mtime +14 -delete
EOF
sudo chmod +x /etc/cron.daily/plausible-backup Copy backups off-server. Analytics data is not high-drama to lose, but rebuilding a year of history from nothing is annoying.
Common pitfalls
- SMTP is required. Plausible Community Edition needs SMTP for user invitations and password resets. Skipping it leaves you with a one-user instance. Postmark and Resend both have generous free tiers.
- ClickHouse OOMs on tiny servers. A CX22 (4 GB) is the realistic minimum. On smaller boxes ClickHouse fights Postgres for RAM.
- The tracking script gets blocked. Some ad blockers block
plausible.io/js/script.jsby default. Self-hosted URLs (analytics.yourcompany.com/js/script.js) are usually unblocked — which is a hidden win. - Google Analytics import. The Community Edition supports GA4 import via the UI, but the mapping loses events. Treat historical GA data as archive, not source of truth.
Updating
cd ~/plausible
git pull
docker compose pull
docker compose up -d
docker image prune -f Plausible cuts community releases every few weeks. Read release notes before major-version upgrades (v2 → v3 will need attention).
What you're paying vs Plausible Cloud / GA
- Plausible on Hetzner CX22: €45/year (~$50) + your time.
- Plausible Cloud (10k pageviews/mo): $108/year — cheaper than self-hosting for small traffic.
- Google Analytics: free in money, real cost in cookie-banner conversion tax and DPA risk.
Self-host Plausible when data-sovereignty matters or you're already on the CX22 for other services. For a single small site, Plausible Cloud is the honest recommendation.
Hosts that work well for Plausible Analytics
Some links are affiliate. We only include hosts we deploy production workloads on. Rankings above are independent of these links.