Guideschevron_rightServers

Servers · 7 min read · Updated

How to Self-Host Umami Analytics

To self-host Umami analytics, download its Docker Compose file, set an APP_SECRET, a two-factor key and your own database password, bind the app to the server itself and put Caddy in front for HTTPS. Sign in with the default admin account, set a new password, add your website and paste the tracking code into its <head>. Umami and its PostgreSQL database run comfortably on a small VPS such as our smallest (6 GB, $37.50 a month), alongside other apps.

1. Prepare the Server

On Ubuntu 24.04, secure the server and install Docker. Point an A record such as stats.example.com at it and allow ports 80 and 443.

2. Get the Compose File and Set Secrets

mkdir ~/umami && cd ~/umami
wget https://raw.githubusercontent.com/umami-software/umami/master/docker-compose.yml
echo "APP_SECRET=$(openssl rand -hex 32)" > .env
openssl rand -hex 32        # for TWO_FACTOR_ENCRYPTION_KEY below
nano docker-compose.yml

In docker-compose.yml, change three things:

  • Replace replace-me-with-a-64-character-hex-string with the second random value, for two-factor sign-in.
  • Change the database password from umami in both places: POSTGRES_PASSWORD and the password inside DATABASE_URL (postgresql://umami:PASSWORD@db:5432/umami). Use letters and digits only, so the URL needs no escaping.
  • Bind the app to the server itself, so only Caddy reaches it: "127.0.0.1:3000:3000" in place of "3000:3000". Docker would otherwise open the port past ufw, as explained in why ufw does not block Docker ports.
docker compose up -d
docker compose ps         # both services should be healthy

3. Add HTTPS With Caddy

sudo apt install -y caddy
sudo tee /etc/caddy/Caddyfile >/dev/null <<'EOF'
stats.example.com {
    reverse_proxy 127.0.0.1:3000
}
EOF
sudo systemctl reload caddy

4. Sign In and Track a Site

  1. Open https://stats.example.com and sign in as admin with the password umami. Umami asks you to set a new password before you continue.
  2. Add your website with its domain.
  3. Edit the website, copy the code under Tracking code and paste it into the <head> of every page. On a Next.js site, use the next/script component.
  4. Visit your site: the visit appears on the Umami dashboard straight away.

Backups and Updates

Everything Umami records is in its PostgreSQL database. Dump it nightly and copy the file off the server, as in backing up a database to S3:

cd ~/umami
mkdir -p ~/backups
docker compose exec -T db pg_dump -U umami umami | gzip > ~/backups/umami-$(date +%F).sql.gz

Update with docker compose pull && docker compose up -d after a backup and a look at the release notes. The same server can host more of your tools, such as Uptime Kuma for monitoring.

Common Questions

  • What is Umami?

    An open-source web analytics app: page views, visitors, referrers, countries, devices and custom events, in one simple dashboard. It is a common self-hosted alternative to Google Analytics, and your visitors' data stays on your server.

  • Which database does Umami use?

    PostgreSQL. Umami's documentation lists PostgreSQL 12.14 or newer, and its Docker Compose file runs PostgreSQL in a container next to the app, so you do not need to install it separately.

  • How big a server does Umami need?

    Very little for most sites: the app and its database fit on a small VPS next to other services. Very busy sites with millions of events a month need more memory and disk for the database as it grows.

  • Can ad blockers block Umami?

    Some do, as they block many analytics scripts by name. Umami documents ways to serve its script under a different name; a self-hosted install on your own domain may also be less likely to be on a blocklist.

Plans and prices

VPS Plans

KVM servers with full root access: your analytics data on a server you control.

See all plans
  • Bronze

    3 vCPU · 6 GB RAM · 75 GB NVMe

    2 TB transfer

    $37.50/mo

    Configure inAshburnDallas
  • Silver

    4 vCPU · 8 GB RAM · 100 GB NVMe

    4 TB transfer

    $46.50/mo

    Configure inAshburnDallas
  • Gold

    6 vCPU · 12 GB RAM · 150 GB NVMe

    6 TB transfer

    $60.00/mo

    Configure inAshburnDallas
  • Diamond

    8 vCPU · 16 GB RAM · 200 GB NVMe

    8 TB transfer

    $73.50/mo

    Configure inAshburnDallas

Network port: 10 Gbps in Ashburn, VA, 50 Gbps in Dallas, TX. Pick the location when you configure.

Keep Reading

All guides