Log inSign up

Metabase dashboards on a server you run

Run the official metabase/metabase image with Docker Compose, point it at a PostgreSQL container through the MB_DB_* variables instead of the built-in H2 file, and proxy 127.0.0.1:3000 through Nginx with a Let's Encrypt certificate. Then connect your databases with read-only accounts and build questions and dashboards in the browser.

Topic: Self-hosted apps · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

What size of server suits Metabase?

Metabase is a Java application, so memory is the figure that matters most: give it a plan with at least 2 GB, and 4 GB if several people run heavy queries or dashboards refresh often. The queries themselves run on your data sources, so a large warehouse does not automatically mean a large Metabase server.

Prepare these items first:

  • Ubuntu 24.04/22.04, Debian 12/13, Rocky Linux 9 or AlmaLinux 9 with a sudo user called deploy.
  • Docker Engine and the Compose plugin from the Docker tutorial; the Docker app image has both ready.
  • A hostname such as bi.example.net with an A record to 198.51.100.24.

Why should Metabase use PostgreSQL for its own data?

Metabase stores users, saved questions, dashboards and settings in an application database. The default is an embedded H2 file inside the container, which is fine for a quick test but can corrupt on an unclean stop and is hard to migrate. The Metabase documentation recommends PostgreSQL or MySQL for anything you keep, so start with PostgreSQL and avoid a migration later.

This application database is separate from the databases you analyse. You will add those later in the admin panel.

How do you define the Metabase stack in Compose?

Create the folder and a password, then write /opt/metabase/compose.yaml.

sudo mkdir -p /opt/metabase && sudo chown deploy:deploy /opt/metabase
cd /opt/metabase
openssl rand -hex 24
services:
  metabase:
    image: metabase/metabase:latest
    restart: unless-stopped
    depends_on:
      - appdb
    ports:
      - "127.0.0.1:3000:3000"
    environment:
      MB_DB_TYPE: postgres
      MB_DB_DBNAME: metabase
      MB_DB_PORT: 5432
      MB_DB_USER: metabase
      MB_DB_PASS: PASTE_PASSWORD
      MB_DB_HOST: appdb
      MB_SITE_URL: https://bi.example.net
      JAVA_TIMEZONE: UTC
      JAVA_OPTS: -Xmx1g
  appdb:
    image: postgres:17
    restart: unless-stopped
    volumes:
      - ./pgdata:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: metabase
      POSTGRES_PASSWORD: PASTE_PASSWORD
      POSTGRES_DB: metabase

JAVA_OPTS: -Xmx1g caps the Java heap so the JVM leaves memory for PostgreSQL on a 2 GB plan. Raise it to -Xmx2g on 4 GB.

How do you start Metabase and test its health endpoint?

Start the stack and follow the log until the startup message appears; the first boot runs migrations and takes a minute or two.

docker compose up -d
docker compose logs -f metabase
curl -s http://127.0.0.1:3000/api/health

When the health check returns {"status":"ok"}, Metabase is ready. Press Ctrl+C to leave the log view; the containers keep running.

How do you put Nginx and HTTPS in front of it?

Install Nginx and Certbot, add a server block that forwards to the loopback port, and request a certificate. On Ubuntu and Debian:

sudo apt install -y nginx certbot python3-certbot-nginx

On Rocky Linux and AlmaLinux, enable EPEL first:

sudo dnf install -y epel-release
sudo dnf install -y nginx certbot python3-certbot-nginx
sudo systemctl enable --now nginx

Create /etc/nginx/conf.d/metabase.conf:

server {
    listen 80;
    listen [::]:80;
    server_name bi.example.net;
    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 300s;
    }
}
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d bi.example.net

On Rocky and Alma, also allow the proxy to open network connections under SELinux with sudo setsebool -P httpd_can_network_connect 1. Open ports 80 and 443 with ufw or firewall-cmd as in the firewall tutorial. The longer read timeout keeps slow dashboard queries from ending in a 504.

How do you connect data sources safely?

Open https://bi.example.net, create the admin account, then add a database under Admin settings, Databases. Give Metabase its own read-only database user so a careless native query can never change production data. For PostgreSQL that looks like this:

CREATE ROLE metabase_ro LOGIN PASSWORD 'choose-a-strong-one';
GRANT CONNECT ON DATABASE shop TO metabase_ro;
GRANT USAGE ON SCHEMA public TO metabase_ro;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO metabase_ro;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO metabase_ro;

If the database lives on another server, allow only this server's IP in that firewall and in pg_hba.conf, as described in remote database access. Avoid exposing a database port to the whole internet just for reporting.

How does Metabase send subscriptions and alerts?

Dashboard subscriptions and alerts go out by email, configured under Admin settings, Email. Fill in an authenticated SMTP relay on port 587 with STARTTLS, a username, password and a from address on example.net, then send the test message. Port 25 from the server may not be open, so ask support with a ticket before you plan direct delivery; the relay route in SMTP relay for apps is the dependable path.

How do you back up and upgrade Metabase?

Everything Metabase knows sits in the PostgreSQL application database, so a dump is a full backup of your questions, dashboards and users.

cd /opt/metabase
docker compose exec -T appdb pg_dump -U metabase metabase | gzip > ~/metabase-$(date +%F).sql.gz

To upgrade, take a dump, then pull and recreate. Metabase migrates its schema on startup and cannot be downgraded afterwards without the dump.

docker compose pull
docker compose up -d
docker compose logs --tail 50 metabase

Pinning a tag such as metabase/metabase:v0.xx.y instead of latest lets you choose when the upgrade happens.

What should you check when Metabase is slow or crashes?

Out-of-memory kills are the usual cause. Run docker stats and free -h; if the container restarts often, lower -Xmx, add a swap file or move to a plan with more RAM via moving to a larger plan. Slow single questions point to the data source: add indexes there or enable model caching in Metabase.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
A2-4a team with daily dashboards2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months
A4-8many users and frequent refreshes4 vCPU, 8 GB RAM, 180 GB NVMe$28.80/mo$86.40 for 3 months

Questions about Metabase dashboards

Can I run Metabase without Docker?

Yes. The JAR file runs on a current OpenJDK release (Java 21 for recent versions) as a systemd service. Docker is shown here because upgrades are a pull and restart. See OpenJDK if you prefer the JAR.

How do I move an existing H2 setup to PostgreSQL?

Metabase includes a load-from-h2 migration command. Stop the old instance, copy the H2 file, and run the command with the new MB_DB_* variables set, following the migration page of the Metabase docs.

Which databases can Metabase query?

PostgreSQL, MySQL, MariaDB, SQLite, MongoDB and several warehouses work out of the box, and community drivers add more. Each connection is set up in the admin panel.

Should the analysed database live on the same server?

It can for small projects. For production data, keeping the database on its own server and granting Metabase a read-only user keeps heavy reports from slowing your application.

How do I reset a forgotten admin password?

If email works, use the reset link on the login page. Without email, Metabase offers a reset-password command run inside the container; check the troubleshooting section of the Metabase docs for the exact syntax of your version.