Back to Blog
Tutorial9 min read2026-06-29

How to Deploy Metabase for Self-Hosted Analytics

Metabase gives your team self-serve BI dashboards without writing SQL. Here's how to deploy it with an external PostgreSQL application database so your questions and dashboards persist.

Ajay Kumar
Ajay Kumar
Founder & DevOps, PandaStack

Metabase is the friendliest open-source BI tool out there — non-technical teammates can build dashboards and ask questions of your data without SQL. Deploying it is mostly easy, but there's one decision that determines whether your work survives a restart: where Metabase stores its *own* metadata. Get that right and the rest is smooth.

Two databases, don't confuse them

This is the single concept that trips people up:

DatabasePurpose
Application databaseMetabase's internal store: users, dashboards, saved questions, settings
Data sourcesThe databases you *analyze* — your production Postgres, MySQL, etc.

By default, the application database is H2 (an embedded file). In a container, that file disappears on redeploy, taking every dashboard with it. For production you must point the application database at an external PostgreSQL instance.

Step 1: Provision the application database

Create a dedicated PostgreSQL database for Metabase's metadata. Don't reuse a database that holds analytics data — keep Metabase's bookkeeping separate. On PandaStack, provision a managed PostgreSQL instance (14.x or 16.x both work fine).

Step 2: Configure Metabase

Metabase reads its application-database config from environment variables:

MB_DB_TYPE=postgres
MB_DB_DBNAME=metabase
MB_DB_PORT=5432
MB_DB_USER=<user>
MB_DB_PASS=<password>
MB_DB_HOST=<host>
# bind to the platform-provided port
MB_JETTY_PORT=3000

With MB_DB_TYPE=postgres set, Metabase skips H2 entirely and stores everything in your managed database.

Step 3: Deploy the container

Metabase ships an official Docker image, so deployment is a single container. On PandaStack:

  1. 1Create a container app using metabase/metabase:latest (pin a specific version tag in production).
  2. 2Link your managed PostgreSQL application database and set the MB_DB_* variables.
  3. 3Bind to the injected port via MB_JETTY_PORT.
  4. 4Attach a custom domain — automatic SSL means HTTPS out of the box.

Metabase's first boot runs database migrations against the application database; this can take a minute. Watch the live logs for Metabase Initialization COMPLETE.

Step 4: Sizing and memory

Metabase runs on the JVM and is memory-sensitive. A starved instance will throw OutOfMemoryError during large query result processing. Give it headroom and, optionally, set the heap explicitly:

JAVA_OPTS=-Xmx2g

Start on a modest compute tier and scale up if you see GC thrash in the logs. Memory-optimized tiers (m1/m2) are a good fit for heavier BI workloads.

Step 5: Connect your data sources

Once Metabase is running, add data sources through the admin UI (Settings → Databases). Metabase supports PostgreSQL, MySQL, MongoDB, ClickHouse, BigQuery, and many more. A few production tips:

  • Create a read-only database user for Metabase. It only needs SELECT; never give it write access.
  • If your data source enforces IP allowlisting, add your Metabase app's egress IP.
  • For large warehouses, lean on Metabase's caching to avoid hammering the source on every dashboard load.

Step 6: Email and scheduled reports

Metabase can email dashboard subscriptions and alerts. Configure SMTP:

MB_EMAIL_SMTP_HOST=smtp.yourprovider.com
MB_EMAIL_SMTP_PORT=587
MB_EMAIL_SMTP_USERNAME=<user>
MB_EMAIL_SMTP_PASSWORD=<pass>
MB_EMAIL_SMTP_SECURITY=starttls
MB_EMAIL_FROM_ADDRESS=metabase@yourdomain.com

Production checklist

  • External PostgreSQL application database (never H2 in prod).
  • Pinned image version, not latest.
  • Read-only credentials for every analyzed data source.
  • Adequate JVM heap; watch memory metrics.
  • SMTP configured if you want alerts/subscriptions.
  • HTTPS via custom domain + automatic SSL.

Honest caveats

Metabase is excellent for self-serve dashboards and ad-hoc questions, but it is not a data warehouse or a transformation tool. Don't ask it to do heavy ETL — model your data upstream (dbt, views, a warehouse) and let Metabase be the presentation layer. The open-source edition lacks some enterprise features (advanced permissions, official SSO in some tiers), so check the feature matrix if your org has strict access requirements.

Wrapping up

The whole game with Metabase is the application database. Point it at managed PostgreSQL instead of embedded H2, give the JVM enough memory, connect read-only data sources, and you have a durable, team-friendly BI platform.

PandaStack's managed PostgreSQL plus one-click container deploys make this a ten-minute job, and the free tier includes both. Spin up your analytics stack at https://dashboard.pandastack.io.

References

  • Metabase documentation: https://www.metabase.com/docs/latest/
  • Running Metabase on Docker: https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker
  • Configuring the application database: https://www.metabase.com/docs/latest/installation-and-operation/configuring-application-database
  • Metabase environment variables: https://www.metabase.com/docs/latest/configuring-metabase/environment-variables
  • Metabase email/SMTP setup: https://www.metabase.com/docs/latest/configuring-metabase/email

Ready to deploy?

Start free on PandaStack.

Start free on PandaStack

More in Tutorial

Browse all Tutorial articles →

See also