# How to Self-Host Umami: A Step-by-Step Guide to Privacy-Focused Web Analytics (With Docker Setup)

**Umami** is a simple, privacy-focused, open-source web analytics solution. It’s lightweight, doesn’t rely on cookies, and offers clean, insightful dashboards — making it a great alternative to tools like Google Analytics if you’re serious about privacy and data ownership.

In this guide, we’ll walk through how to self-host Umami on your server, both **manually** and using **Docker**. Whether you prefer fine-grained control or a quick containerized deployment, you’ll find everything you need here.

### 🚀 Why Self-Host Umami?

* **Data Privacy**: You control your analytics data.
    
* **Lightweight**: Fast and minimal resource consumption.
    
* **No Tracking Consent Needed**: Since Umami doesn’t use cookies or collect personal data.
    
* **Open-Source**: Free to use and customizable.
    

### Manual Setup Guide for Umami

### 🛠️ Prerequisites

* A Linux-based server (Ubuntu recommended)
    
* Node.js (v18.18 or newer)
    
* MySQL (v8+) or PostgreSQL (v12+)
    
* Nginx (for reverse proxy)
    
* Domain name (optional but recommended)
    

### 1️⃣ Install Dependencies

#### Node.js & npm

```bash
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
node -v
npm -v
```

#### Database (PostgreSQL Example)

```bash
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo -u postgres psql
CREATE DATABASE umami;
CREATE USER umami WITH ENCRYPTED PASSWORD 'strongpassword';
GRANT ALL PRIVILEGES ON DATABASE umami TO umami;
```

### 2️⃣ Install Umami

```bash
git clone https://github.com/umami-software/umami.git
cd umami
npm install
cp .env.example .env
```

Edit your `.env` file to include your **database credentials**:

```bash
DATABASE_URL=postgresql://umami:strongpassword@localhost:5432/umami
HASH_SALT=some-random-salt-value
```

### 3️⃣ Build and Start Umami

```bash
npm run build
npm start
```

(Optional) Use PM2 to keep the app running:

```bash
npm install pm2 -g
pm2 start npm --name umami -- start
pm2 save
```

### 4️⃣ Set Up Nginx Reverse Proxy (Optional but recommended)

```nginx
server {
    server_name analytics.yourdomain.com;
    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
```

Don’t forget SSL! Use Let’s Encrypt or another certificate provider.

### ⚓ Docker Setup Guide for Umami

If you want a **quicker and easier** deployment option, **Docker** is your friend!

### 🛠️ Prerequisites

* Docker
    
* Docker Compose (optional, but helpful)
    
* A server (local or cloud)
    

### 1️⃣ Clone the Repository

```bash
git clone https://github.com/umami-software/umami.git
cd umami
```

### 2️⃣ Modify Docker Environment Variables

Rename and edit the `.env` file:

```bash
cp .env.example .env
```

Modify the following variables as needed (Postgres example):

```bash
DATABASE_URL=postgresql://umami:strongpassword@db:5432/umami
HASH_SALT=some-random-salt-value
```

### 3️⃣ Create the Docker Compose File

Here’s a sample `docker-compose.yml` for Umami with PostgreSQL:

```yaml
version: '3'

services:
  db:
    image: postgres:15
    restart: always
    environment:
      POSTGRES_DB: umami
      POSTGRES_USER: umami
      POSTGRES_PASSWORD: strongpassword
    volumes:
      - umami-db-data:/var/lib/postgresql/data

  umami:
    image: ghcr.io/umami-software/umami:postgresql-latest
    restart: always
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgresql://umami:strongpassword@db:5432/umami
      HASH_SALT: some-random-salt-value
    depends_on:
      - db

volumes:
  umami-db-data:
```

### 4️⃣ Start the Containers

Run the following command to spin up the services:

```bash
docker-compose up -d
```

### 5️⃣ Access Your Umami Instance

Visit `http://your-server-ip:3000` or your configured domain.

Default login credentials:

```plaintext
Username: admin
Password: umami
```

Make sure to **change your password immediately** after logging in!

### 🔒 Optional: Secure Umami with SSL + Nginx (Recommended)

Add an Nginx reverse proxy and set up SSL for your Docker deployment too! Same as the manual setup Nginx block above.

### ✅ Conclusion

That’s it! You’ve successfully self-hosted Umami either **manually** or using **Docker**. You now have a privacy-first analytics solution where you **own your data** and keep your users’ privacy intact.

For more information or advanced configurations, refer to the official Umami documentation: [https://umami.is/docs](https://umami.is/docs)

### 💡 What’s Next?

* Connect your websites by adding the Umami script:
    

```xml
<script async defer data-website-id="YOUR-WEBSITE-ID" src="https://analytics.yourdomain.com/script.js"></script>
```

* Create custom reports and share dashboards.
    
* Explore advanced tracking options with events and goals.
    

👉 Have questions or feedback? Drop them in the comments!

👉 Like the post if you found it helpful!
