# Self-host Metabase

> Business intelligence tool: connects to databases, lets people ask questions with a query builder or SQL, and builds dashboards; can be embedded in other apps. Run your own Metabase on an always-on EnvHaven workspace by asking its coding agent: one request installs it, puts it on an HTTPS address and locks it down. What the agent takes care of, and the manual route.

_Updated November 23, 2026_

Running your own Metabase usually means a list of server chores: a machine that stays on, Docker or a runtime, a reverse proxy with certificates, a domain, and the settings that make Metabase behave behind all of it. On an EnvHaven workspace you skip the list. You ask the coding agent, and it does the work while you watch.

## Just ask your agent

Open a Plus workspace (Metabase runs in Docker, which Plus and Pro include), tap **Launch** to start any coding agent (Claude Code, Codex, OpenCode or another), and ask it:

```text
Set up Metabase on this workspace and give me the link. Follow https://envhaven.com/self-host/metabase.md
```

Then open the link it sends and create your Metabase account straight away, before anyone else finds the address. That is the whole request: the address in it is this page's Markdown copy, and the agent follows the instructions for it further down, with every setting Metabase's docs require.

## Or keep it private with Tailscale

The preview URL puts Metabase on the public internet, which suits something other people need to reach. For an app only you and your household use, your tailnet is the better home: Tailscale gives Metabase an HTTPS address that only your own devices, signed in to your Tailscale account, can open. Save a Tailscale auth key in the workspace's **Vars** pane as `TS_AUTHKEY`, and ask the agent:

```text
Set up Metabase on my tailnet instead of the preview URL. Follow https://envhaven.com/self-host/metabase.md and https://envhaven.com/guides/self-host-privately-with-tailscale.md
```

- A Tailscale container runs beside Metabase, so it keeps its private address through workspace restarts and updates, and every app you set up this way gets an address of its own.
- Anything other services have to reach, such as a webhook, still needs a public address. [Keep self-hosted apps private with Tailscale](https://envhaven.com/guides/self-host-privately-with-tailscale) covers both, and what Tailscale's free plan includes.

| At a glance |  |
| --- | --- |
| What it is | Databases, backends and analytics |
| License | AGPL-3.0 for the open-source edition |
| Runs as | Docker (`metabase/metabase (open source); metabase/metabase-enterprise for Pro or Enterprise`) |
| Memory | Not documented |
| Plan that fits | Plus or larger |
| Web port | 3000 |
| Documentation | [www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker) |

## What your agent takes care of

- **Installing it.** Metabase runs from the official image, `metabase/metabase (open source); metabase/metabase-enterprise for Pro or Enterprise`, with its data in folders under `~/apps/metabase`.
- **Putting it on an HTTPS address.** The workspace's preview URL serves it, and your own domain can too.
- **Locking it down first.** What Metabase's docs say to set before it faces the internet, below.
- **Telling you what to back up**: the application database: external PostgreSQL or MySQL via MB_DB_* variables, or the embedded H2 file (/metabase.db/metabase.db.mv.db in the Docker image, metabase.db.mv.db beside the JAR) and MB_ENCRYPTION_SECRET_KEY (store and back it up separately) ([docs](https://www.metabase.com/docs/latest/installation-and-operation/backing-up-metabase-application-data)).

### The settings it needs behind a proxy

- `MB_SITE_URL`: Public address people use (scheme included); drives email links, auth redirects, SSO and embedding. Wrong http versus https can lock you out. ([docs](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables))
- `MB_SITE_URL` must match how Metabase is reached: Set it explicitly; if unset it is learned from the first authenticated admin's request headers. ([docs](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables))
- `MB_REDIRECT_ALL_REQUESTS_TO_HTTPS`: Redirects all traffic to HTTPS when the site URL is HTTPS; default false. Use with a proxy that sends X-Forwarded-Proto. ([docs](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables))
- X-Forwarded-Proto request header: When TLS ends at the proxy: set MB_SITE_URL to https://<hostname>, MB_REDIRECT_ALL_REQUESTS_TO_HTTPS to true, send X-Forwarded-Proto: https, and restrict the HTTP port to the proxy. ([docs](https://www.metabase.com/docs/latest/installation-and-operation/security-best-practices-self-hosting))
- `MB_JETTY_HOST` and `MB_JETTY_PORT`: Listen address (localhost for the JAR, 0.0.0.0 for Docker) and port (default 3000). ([docs](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables))
- `MB_SESSION_COOKIE_SAMESITE`: SameSite value of the session cookie, default lax; matters for embedding on another domain. ([docs](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables))

### Before it faces the internet

- The first account created at /setup becomes an admin, so finish setup before announcing the URL. ([docs](https://www.metabase.com/docs/latest/getting-started/setting-up-metabase))
- The setup token authorises creating the initial user and is cleared once used. ([docs](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables))
- Do not expose the Metabase port directly; use a proxy and a firewall. ([docs](https://www.metabase.com/docs/latest/installation-and-operation/security-best-practices-self-hosting))
- Set MB_ENCRYPTION_SECRET_KEY (and MB_SESSION_SECRET_KEY) before first use. ([docs](https://www.metabase.com/docs/latest/installation-and-operation/security-best-practices-self-hosting))
- Session secret keeps application-database access alone from minting sessions. ([docs](https://www.metabase.com/docs/latest/installation-and-operation/security-best-practices-self-hosting))
- Use a production application database, not H2. ([docs](https://www.metabase.com/docs/latest/installation-and-operation/security-best-practices-self-hosting))

## Things to ask next

Everything after the install is one more sentence to the agent. Some that come up:

- "Create the tables for a simple CRM: companies, contacts and deals."
- "Seed it with sample data so I can try the interface."
- "Move Metabase to app.example.com." Add the domain on the dashboard's Domains page with a CNAME to `domains.envhaven.app`, and the agent changes Metabase's address settings to match.
- "Update Metabase to the latest release." It pulls the new image and recreates the container, data kept.

## Instructions for the agent

The agent reads these from the page's Markdown copy. They also work pasted on their own, if you would rather give them in your own words.

```text
Set up Metabase on this workspace and serve it at my preview URL.
- Use Docker Compose with the official image, metabase/metabase (open source); metabase/metabase-enterprise for Pro or Enterprise, starting from the docs' compose file: https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker. If `docker compose` is missing, install the Compose plugin into ~/.docker/cli-plugins first.
- The docs' setup includes: none to start: ships an embedded H2 application database (not for production); PostgreSQL (or another supported database) as the production application database; a JVM is bundled in the image.
- Keep the compose file in ~/apps/metabase and all of its data in folders there (bind mounts, not named volumes), with restart: unless-stopped on every service.
- This server has no firewall, so publish no port on its public IP, and drop host networking and privileged mode from the docs' compose file. Docker runs on the host: connect this workspace to the compose network and relay my preview URL's port to Metabase's port 3000.
- The preview URL terminates HTTPS in front of Metabase: serve plain HTTP on its port, and trust the forwarded headers the relay passes on.
- Set what "The settings it needs behind a proxy" lists on https://envhaven.com/self-host/metabase.md for the preview URL, as Metabase's docs describe for running behind a proxy; skip any that apply only when Metabase serves HTTPS itself.
- Before the preview URL serves it, apply what "Before it faces the internet" lists on https://envhaven.com/self-host/metabase.md.
- When it answers at the preview URL, send me the link and tell me what to back up.
- If I asked for my tailnet instead of the preview URL, set Metabase up the same way but follow https://envhaven.com/guides/self-host-privately-with-tailscale.md for the network: no preview URL, no relay.
```

## What to know

- In Docker, Metabase's containers keep running when the workspace restarts or updates. The relay from the preview URL is a process in the workspace, so after a restart or an update, ask the agent to restore it.
- JVM application: it holds a fixed share of RAM (about a quarter of the machine by default); the docs cover Java heap OutOfMemoryError crashes and how to raise the heap. ([docs](https://www.metabase.com/docs/latest/troubleshooting-guide/running))
- The default H2 application database lives in the container filesystem and is not meant for production. ([docs](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker))
- Email (alerts, subscriptions, invitations) needs your own SMTP server; the setting defaults to null. ([docs](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables))
- Anonymous usage data and update checks are on by default and need outbound HTTPS. ([docs](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables))
- The JAR listens on localhost only by default (the Docker image on all interfaces), so a proxy on another host needs MB_JETTY_HOST changed. ([docs](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables))
- Metabase expects its own host rather than a path under one, so it takes the workspace's preview URL or a domain of its own.
- A workspace has one preview URL and one custom domain, both serving the same port, so it puts one app on a public address at a time.

## Without a workspace

The manual route, on a server you run:

1. Rent a Linux VPS, secure SSH, and create a user for the app.
2. Install Docker and write a compose file from the official image.
3. Put a reverse proxy in front (Caddy, nginx or Traefik), get certificates, and point a domain at the server.
4. Set the proxy settings listed above for that domain, and pass WebSocket upgrades through the proxy if the app uses them.
5. Keep the firewall closed except for the proxy, and schedule backups and updates.

Metabase's own [documentation](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker) covers each step for its install methods.

## Sources

Facts about Metabase come from its own documentation, checked on 2026-11-23:

- [metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker](https://www.metabase.com/docs/latest/installation-and-operation/running-metabase-on-docker)
- [metabase.com/docs/latest/configuring-metabase/environment-variables](https://www.metabase.com/docs/latest/configuring-metabase/environment-variables)
- [metabase.com/docs/latest/installation-and-operation/security-best-practices-self-hosting](https://www.metabase.com/docs/latest/installation-and-operation/security-best-practices-self-hosting)
- [metabase.com/docs/latest/configuring-metabase/settings](https://www.metabase.com/docs/latest/configuring-metabase/settings)
- [metabase.com/docs/latest/troubleshooting-guide/running](https://www.metabase.com/docs/latest/troubleshooting-guide/running)
- [metabase.com/docs/latest/installation-and-operation/backing-up-metabase-application-data](https://www.metabase.com/docs/latest/installation-and-operation/backing-up-metabase-application-data)
- [metabase.com/docs/latest/getting-started/setting-up-metabase](https://www.metabase.com/docs/latest/getting-started/setting-up-metabase)

## Keep reading

- [Self-host any app with your agent](https://envhaven.com/self-host)
- [Self-host Supabase](https://envhaven.com/self-host/supabase)
- [Self-host Appwrite](https://envhaven.com/self-host/appwrite)
- [Self-host NocoDB](https://envhaven.com/self-host/nocodb)
- [Self-host Baserow](https://envhaven.com/self-host/baserow)
- [AI agent hosting](https://envhaven.com/guides/ai-agent-hosting)

Source: https://envhaven.com/self-host/metabase
