How to Install Umami on a VPS: Cookie-Free Self-Hosted Web Analytics
One dashboard for the most basic quest
ion about your site
Every site owner eventually arrives at the same question: which pages do people actually open, where do they come from, and what devices do they use. Without an answer, decisions about content and layout rest on gut feeling. On the other hand, large analytics services ask you to hand visitor data over to a third-party server, complete with a cookie-consent banner that sends some visitors straight back out.
Umami offers a sensible middle path. You install it on your own server, the data lives in your own database, and tracking uses no cookies. This guide covers installing Umami with Docker and PostgreSQL on a VPS, adding a first website, installing the tracking script, and confirming that data starts flowing. By the end, you will have your own analytics dashboard, available any time, with no dependence on an outside service.
One point deserves clearing up from the start: "cookie-free" does not mean "trace-free". Umami still records visits, pages viewed, referrers, operating systems, and visitor devices in your database. The difference is that it plants no tracking cookie in a visitor's browser and builds no cross-site profile. The data collected stays yours, and you decide how long to keep it.
Before you start
Get the following in place so the installation runs without friction:
- A Linux VPS with Docker and the Docker Compose plugin already installed. Check with
docker --versionanddocker compose version; both should print version numbers, not errors. - A domain or subdomain for the Umami dashboard, such as
analytics.example.com, with a DNS record already pointing at your VPS IP. Visitors reach it indirectly through the tracking script, and you use it to open the dashboard. - SSH access to the VPS with sudo rights or as root.
- Around 1 GB of free RAM for Umami and PostgreSQL. Umami itself is light, but PostgreSQL still needs reasonable working room.
Step 1: Prepare the directory and the Compose file
Log in to the VPS over SSH, then create a dedicated directory for Umami. Giving each service its own directory makes later maintenance far easier: configuration files, data, and logs never get mixed up with other services.
mkdir -p ~/services/umami
cd ~/services/umami
Next, generate two random values: one for the PostgreSQL database password, one for Umami's APP_SECRET. APP_SECRET secures Umami's authentication tokens, so it must be long, random, and different from the database password.
openssl rand -hex 32
openssl rand -hex 32
Keep both outputs handy for a moment. Now create a compose.yaml file with the following contents, replacing both placeholders with the random values you just generated:
services:
umami:
image: docker.umami.is/umami-software/umami:latest
container_name: umami
ports:
- "127.0.0.1:3000:3000"
environment:
DATABASE_URL: "postgresql://umami:REPLACE_WITH_DB_PASSWORD@db:5432/umami"
DATABASE_TYPE: postgresql
APP_SECRET: REPLACE_WITH_APP_SECRET
depends_on:
db:
condition: service_healthy
init: true
restart: always
healthcheck:
test: ["CMD-SHELL", "curl http://localhost:3000/api/heartbeat"]
interval: 5s
timeout: 5s
retries: 5
db:
image: postgres:15-alpine
container_name: umami-db
environment:
POSTGRES_DB: umami
POSTGRES_USER: umami
POSTGRES_PASSWORD: REPLACE_WITH_DB_PASSWORD
volumes:
- ./data:/var/lib/postgresql/data
restart: always
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5
Note two details in this file. First, port 3000 is bound to 127.0.0.1 only, not to every interface. That means Umami cannot be reached directly from the internet; public access is arranged later through a reverse proxy with HTTPS. Second, the value of REPLACE_WITH_DB_PASSWORD must match exactly in DATABASE_URL and in POSTGRES_PASSWORD. A single differing character is enough to stop Umami from connecting to the database.
A note on the image version: this guide uses the latest tag from Umami's official registry so you start from the release available right now. If you want an installation you can reproduce exactly later, replace latest with the release version number you note down after the first successful install.
Step 2: Start the containers and check their status
Run Compose from the same directory:
docker compose up -d
This downloads the Umami and PostgreSQL images, creates the data volume, and starts both containers in the background. On its first run, Umami creates every table it needs in the database automatically. Wait about 30 seconds, then check the status:
docker compose ps
The expected result shows both containers running and healthy, roughly like this:
NAME IMAGE STATUS
umami docker.umami.is/umami-software/umami Up (healthy)
umami-db postgres:15-alpine Up (healthy)
If Umami still shows starting after a minute, check its logs before changing anything:
docker compose logs umami --tail 50
A database-connection error almost always means the password in DATABASE_URL does not match POSTGRES_PASSWORD. Fix the Compose file, then run docker compose up -d again; Compose will recreate the Umami container with the new configuration.
Step 3: Open the dashboard and change the default password immediately
Umami listens on port 3000 on the VPS. For an initial check, you can open a temporary tunnel over SSH from your own computer:
ssh -L 3000:localhost:3000 root@YOUR_VPS_IP
Then open http://localhost:3000 in a browser. For long-term use, point your subdomain at the VPS and put an Nginx reverse proxy with HTTPS in front; Umami does not serve HTTPS itself, so this layer is required before the dashboard is opened to the internet.
The first time you open the dashboard, Umami provides a built-in account with username admin and password umami. This is a step that must not wait: log in, open Settings, replace the admin password with a strong one, and store it in your password manager. A default account left with its default password is the same as leaving your analytics dashboard door open to anyone who finds its address.
Step 4: Add a website and copy the tracking code
Once logged in as admin, add the site you want to measure. From the dashboard, open Settings, go to the Websites section, and add a site with its name and domain, for example the name "Rnevio Blog" with the domain example.com. Umami generates a site ID in UUID form for that site.
To get the tracking code, click the Edit button for the site you just created, then open the Tracking code section. Copy the code shown there exactly as it is. Its general shape looks like this, with the domain and ID already fitted to your installation:
<script defer src="https://analytics.example.com/script.js" data-website-id="YOUR-SITE-ID"></script>
Do not retype this code from memory. Copy it straight from the dashboard, because a site ID wrong by a single character will send data to the wrong place or record nothing at all.
Paste that code into the <head> section of every page you want to measure. On a static site, that means the header template shared by all pages. On a single-page application (SPA), install it once in the main document; Umami automatically records page navigation in SPAs with no extra configuration. On Next.js, Umami's official docs recommend using the next/script component rather than a plain <script> tag.
Step 5: Verify that data is actually arriving
This step is often skipped, yet it takes only a minute. Open your site in a browser, visit two or three pages, then return to the Umami dashboard and open that site. Data should appear right away: the visit count rises, the pages you opened are listed, and the referrer shows up.
If the dashboard is still empty, work through this order:
- Open the browser developer tools (F12), switch to the Network tab, and reload your site. Look for requests to your Umami domain. If those requests fail, the problem lies in the domain or reverse-proxy path, not in Umami.
- Check whether an ad blocker in your browser is stopping the tracking script. Umami's official docs name ad blockers as a common cause of missing data. Try from a browser without an ad blocker to confirm.
- Compare the site ID in the installed script against the ID shown in the dashboard. A mismatch of a single character is enough to break recording.
If all three checks pass and data is still missing, inspect the Umami logs with docker compose logs umami --tail 50 and look for error messages from the time of your test visit.
Step 6: Secure and maintain the installation
The following maintenance habits keep Umami healthy over the long term:
- Back up the database regularly. Analytics data lives in the
./datavolume inside the Umami directory. Back up that directory together withcompose.yaml. Without a backup, one disk failure wipes out the entire statistics history. - Update regularly. To update the images, run
docker compose pullfollowed bydocker compose up --force-recreate -dfrom the Umami directory. The second command recreates containers with the newest images without deleting the data volume. - Limit who can open the dashboard. Beyond a strong admin password, consider extra authentication at the reverse proxy or an allowlist of IPs, especially if the dashboard never needs to be opened from anywhere.
- Watch disk usage. An analytics database grows with traffic. Check the size of
./dataevery few months, and decide on a data-retention policy before the VPS disk fills up in the middle of the night
Common mistakes and how to fix them
| Symptom | Most likely cause | Fix |
|---|---|---|
| Umami container fails to start with a database-connection error | Password in DATABASE_URL differs from POSTGRES_PASSWORD | Make both values identical, then run docker compose up -d again |
| Dashboard unreachable from outside the VPS | Port bound to 127.0.0.1 only and no reverse proxy installed | Put an Nginx reverse proxy with HTTPS in front of localhost:3000 |
| No data after the script is installed | Ad blocker stopping the script, or wrong site ID | Test from a browser without an ad blocker and match the site ID against the dashboard |
| Login errors after a configuration change | APP_SECRET changed after accounts were created | Restore the old APP_SECRET, or reset the account if a change is truly required |
| VPS disk slowly filling up | Analytics database growing with traffic | Check the size of ./data and set a data-retention policy |
| An update makes Umami behave oddly | The latest image moved to a new major release | Note the version that works well and pin that tag in compose.yaml |
Summary table
| Item | Detail |
|---|---|
| Service | Umami, cookie-free self-hosted web analytics |
| Database | PostgreSQL 15 (postgres:15-alpine image) |
| Containers | umami and umami-db, managed by one compose.yaml |
| Internal port | 3000, bound to 127.0.0.1 only |
| First login | Username admin, password umami (must be changed at once) |
| Tracking code | Copied from the Tracking code section in the dashboard, placed in <head> |
| Data recorded | Visits, pages, referrers, operating systems, devices |
| Maintenance | Back up the ./data volume, update with docker compose pull and --force-recreate |
Final checklist
- Both containers show healthy in
docker compose ps. - The default admin password has been replaced with a strong one.
- The dashboard is reachable only through a reverse proxy with HTTPS, not through a publicly open port 3000.
- The site is added in the dashboard and the tracking code is copied straight from the Tracking code section.
- The tracking script sits in the
<head>of every page to be measured. - A test visit is recorded in the dashboard, including its page and referrer.
- Backups of the
./datavolume andcompose.yamlare scheduled. - A regular update routine is noted, including
docker compose pulland--force-recreate.
Which site will you measure first with Umami, and which metric do you most want to see move after a month? Tell us in the comments, so other readers can compare which metrics matter most for different kinds of sites.
Read also: A guide to running Docker rootless for safer containers


Diskusi
Ada pertanyaan atau pengalaman yang ingin dibagikan?
Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.
Tulis komentar