On this page
- What size of server suits Metabase?
- Why should Metabase use PostgreSQL for its own data?
- How do you define the Metabase stack in Compose?
- How do you start Metabase and test its health endpoint?
- How do you put Nginx and HTTPS in front of it?
- How do you connect data sources safely?
- How does Metabase send subscriptions and alerts?
- How do you back up and upgrade Metabase?
- What should you check when Metabase is slow or crashes?
- Questions
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.netwith an A record to198.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 24services:
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: metabaseJAVA_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/healthWhen 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-nginxOn 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 nginxCreate /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.netOn 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.gzTo 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 metabasePinning 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.
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.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM