Connecting Metabase to MongoDB: what the integration does
A team that wants dashboards and saved questions over MongoDB collections in a self-hosted Metabase starts with one question: what does the connection let Metabase read, and who maintains it? Metabase connects to MongoDB either through discrete fields (host, database name, port, username, password and an optional authentication database) or by pasting a connection string, and it supports MongoDB from the oldest supported version to the latest stable release. Confirm the exact MongoDB version you run against the current list in the Metabase MongoDB documentation before you pick a connection method.
Once configured, the connection is a read path from Metabase's application server to your database. Metabase's application sends queries to MongoDB, reads results and caches or renders them for users, so the network route from the Metabase host to the MongoDB deployment, the account Metabase uses and the TLS settings all sit on your side of the boundary. Decide early which MongoDB user Metabase authenticates as, whether that user has read access only to the databases and collections you intend to expose, and how the connection string or password is stored on the Metabase host. Those decisions shape the security review that follows any rollout.
DeployOpen's role in this integration is implementation work on infrastructure you control: planning the network path, creating the read-only account with your database team, configuring the connection in your self-hosted Metabase, and documenting the result for your security and compliance reviewers. DeployOpen does not operate your MongoDB cluster or issue any assurance about it. Ask your database team to confirm cluster ownership, backup responsibility and the authentication mechanism before scoping the work, because those answers determine what the integration can safely expose.
Prerequisites before connecting Metabase to MongoDB
Most MongoDB connection problems are settled before anyone opens the Metabase admin panel. The cards below cover the supported version range, the database user, network and TLS choices, and the Metabase plan and application database that must already be in place.
Confirm the supported MongoDB version
Metabase supports MongoDB from the oldest supported version up to the latest stable release. Confirm the exact range for your Metabase version in the MongoDB connection documentation before you set up the cluster, because the driver behavior and supported versions can change between Metabase releases. Record the MongoDB version you run, including any managed service edition, so the connection test results can be matched to it later.
MongoDB docsCreate a read-only database user
Create a dedicated MongoDB user for Metabase that holds only read roles on the databases and collections it should query. Do not reuse an administrator account or an application account. Metabase syncs schema and runs queries under this user, so its grants set the ceiling for what any Metabase user can ever see, regardless of Metabase permissions.
Set the authentication database
MongoDB stores users in an authentication database, which is often admin but is not always the database you query. Decide which database holds the Metabase user and record it, because Metabase asks for it as an optional field when you enter host, database, port and credentials. A wrong authentication database produces login failures that look like wrong passwords, so check it first when the test fails.
Plan network reachability
Confirm that the MongoDB hosts or replica set members accept connections from the address Metabase uses, whether that is a VM, a container, or a Kubernetes pod. Check firewall rules, security groups, DNS names and replica set member hostnames, since a driver can connect to a seed host and then fail on a member name it cannot resolve. If the cluster sits behind a private network, decide whether Metabase reaches it directly or through a bastion before you start.
Enable TLS on the MongoDB side
Ask the database team whether client connections to the cluster must use TLS and which certificate authority signed the server certificate. Metabase connects with the settings you supply, so an unencrypted path between Metabase and the cluster carries the credentials and query results across the network in the clear. Collect the CA certificate and the required connection options now, and confirm the exact settings in the MongoDB documentation for your Metabase version.
Have the Metabase plan and application database ready
Row-level security on MongoDB depends on a paid plan, so decide between Open Source and Pro or Enterprise before you configure access rules. Run Metabase on a PostgreSQL application database for production rather than the embedded H2 database, so that the connection settings and sync state survive upgrades and restores. Complete both steps before the MongoDB connection is created, so permission design is not retrofitted later.
How to configure the MongoDB connection in order
This sequence takes a MongoDB database from a dedicated read-only account to a connected Metabase database with a synced schema and sample results you have checked against the source. Each step ends with a check you can run before moving on.
Create a least-privilege MongoDB user
A database administrator creates a dedicated MongoDB user for Metabase with read access only to the databases and collections it needs, and no write or administrative roles. Record the username, password and the authentication database the user was created in, because the connection form asks for each of them. Confirm the account by logging in with it from a MongoDB shell or client and running a read on one approved collection. Check that a write attempt is refused. If either check fails, fix the role grants before you configure Metabase, since a broad account will carry into every query Metabase runs. Ask your MongoDB team to confirm the role scope in writing.
Choose the field form or connection string
Decide whether to enter the host, database name, port, username, password and optional authentication database into the separate fields, or paste a full connection string. The field form is easier to review because each value sits in its own box, and it keeps the password out of a single long string. A connection string suits deployments that already define replica set names, TLS options or other parameters in one value. Whichever you choose, store the password in your secrets manager and enter it only in Metabase, not in tickets or shared notes. Note the choice in your runbook so the next person knows how the connection was built.
Enter the connection details in Metabase
A Metabase administrator opens Admin settings, selects Databases, chooses Add database and selects MongoDB. Enter the values from the first two steps, or paste the connection string, and set the display name so analysts can tell this source apart from others. Leave the sync and scan options at their defaults until the first run is complete. Save the form without any sample data or a test database name. The form is complete when every required field is filled and no value is left as a placeholder. Confirm the saved name and the database it points to match the source you intended.
Run the connection test
Select the test or save action in the database form and wait for Metabase to report whether it reached the MongoDB server. A failure usually points to network routing, a wrong authentication database, a TLS requirement that was not enabled, or a password that was copied incorrectly. Fix one value at a time and retest, and review the Metabase server logs if the error message is unclear. The check passes when Metabase reports a successful connection and the database appears in the data picker. If the test passes only from your workstation, confirm that the Metabase host itself has the network path.
Trigger the first schema sync
Start a manual sync from the database settings so Metabase reads collection names and infers field types from a sample of documents. Document-based collections can have fields that appear in only some records, so the inferred schema may not show every field a team expects. Wait for the sync status to show complete, then open the database in the data browser. The check passes when the collections you approved appear and the ones you excluded do not. If an expected collection is missing, confirm the MongoDB user can read it before you change Metabase settings.
Preview a collection and compare sample documents
Open one approved collection in the data browser and use the preview to view a small set of rows. Pick a document you can also find in the MongoDB shell, then compare a few field values between the two tools. Run a simple question that counts documents or filters on one field, and check the result against a count taken directly from MongoDB using the same filter. Nested fields may appear as flattened or JSON-like values, so confirm how they render before building dashboards on them. The step is complete when the preview and the direct query agree for the sample you chose. Record the test question so it can be rerun after upgrades or permission changes.
How MongoDB documents map to Metabase tables
Metabase presents each MongoDB collection as a table, so people building questions pick a collection and then work with its fields. Document databases do not enforce a fixed schema, so Metabase has to infer the fields it shows by sampling documents during sync. The inferred field list is an estimate based on the documents Metabase happened to read, not a guarantee of every field the collection holds. Fields nested inside subdocuments and arrays appear with their own names and types, and people building questions must work with those names directly. Before any dashboard depends on a collection, a data owner should confirm that the fields people need are present, that their types are what the team expects, and that a field sampled as one type is not also stored as another in other documents.
Field types are where the risk sits. When the same field holds a string in some documents and a number or date in others, the type Metabase assigns depends on what it sampled, and a filter, sum or date grouping can then return results that look complete but leave out documents of the other type. Arrays and deeply nested objects add a second layer, because a question can expose a flattened view that does not behave like the rows of a relational table. Plan a sampling check after each sync for the collections behind important dashboards: compare the fields Metabase shows against a sample of raw documents, and record any field whose type varies. Confirm how sampling and type inference currently behave, along with any settings that control them, in the Metabase MongoDB documentation and the MongoDB documentation for your server version before you model dashboards on nested data. If a collection needs a stable, flat shape for reporting, that reshaping is usually better done in a pipeline that writes to a relational store, which the sibling topics on database connections cover.
Mapping MongoDB concepts to Metabase objects
This table maps each MongoDB concept to the Metabase object it becomes, and notes what you must check in your own environment before relying on it. Read it as a checklist for the connection and its access model, since MongoDB permissions and Metabase permissions are separate layers that both need to be correct.
| MongoDB concept | Metabase object | What you must verify in your environment |
|---|---|---|
| Database | Database connection (one per MongoDB database you connect) | Which databases the Metabase user is meant to reach, and whether each needs its own connection in Metabase |
| Collection | Table | Whether the collections Metabase lists match what analysts expect, and which collections should be excluded from sync |
| Top-level document fields | Columns, with types inferred from sampled documents | Field type consistency across documents, since mixed types in one field can produce unexpected column types |
| Nested documents and arrays | Nested fields, shown as dot-notated or flattened columns depending on sync results | How deeply nested fields appear after sync and whether analysts can query the paths they need |
| Authentication database | Authentication database field in the connection settings, or the authSource value in a connection string | That the user was created in the database named here, since a mismatch causes login failures that look like bad passwords |
| User roles on the database | What the Metabase user can read, enforced by MongoDB rather than Metabase | That the role grants read only on the required databases and collections, and no write or admin privileges |
| Row-level restrictions | Row-level security set in Metabase, supported on MongoDB | That the filter logic works on your document shape and that Metabase permissions are the only route to restricted rows |
| Column-level restrictions | Not supported on MongoDB in Metabase | That sensitive fields are removed by the MongoDB role or by modeling elsewhere, since Metabase cannot hide individual columns |
| Schema and sample changes | Sync and field value scanning results | How often sync runs and whether new fields appear in analysts' views after documents change shape |
How queries flow from Metabase to MongoDB
A question starts in the browser, passes through the Metabase application, which reads its own settings and saved content from the application database, and then runs against MongoDB over a connection you define with fields or a connection string. Credentials for the MongoDB user are stored by Metabase, so check where the application database and the Metabase host sit inside your network boundary. Row-level permissions are applied by Metabase before the query is sent, which is why the MongoDB user's own rights should also be scoped narrowly.
Query path from a Metabase user to MongoDB, with the trust boundary and permission step marked.
What row and column security does on MongoDB
Metabase's data isolation guidance lists row-level security as the supported isolation method for MongoDB. In practice, this means you can restrict which documents a group sees by defining a rule on a field that exists in the collection, such as a tenant identifier, region or owning team. The rule filters results at query time, so a user in a restricted group runs questions against the same collection but receives only the matching records. Whether this works depends on the data itself: every document you need to isolate must carry the field the rule references, and documents with missing or inconsistent values are a common source of unexpected visibility.
- Field presence: each isolated document needs the attribute the rule uses, and nested or array fields need testing before you rely on them.
- Value consistency: the same tenant or region should use one spelling and type across collections.
- Joins across collections: confirm how questions that combine collections apply the rule to each side.
- Write paths: rules govern reading in Metabase, not what applications write to MongoDB.
- Testing with real accounts: sign in as a restricted user and check counts against a known result.
Confirm the current row-level behavior for your Metabase version in the data isolation guidance before you design the rule set.",
Column-level security is not supported for MongoDB in Metabase. A group cannot be limited to certain fields of a collection while still seeing the rest of the documents. If a sensitive field such as a national identifier, salary or diagnosis code sits in the same collection as fields analysts need, Metabase will not hide that single field from the restricted group through its permission settings. The practical consequence is that the access boundary has to be drawn at the document level or at the collection level, not at the field level.
- No field masking: you cannot hide one field from a group through Metabase permissions on this source.
- Collection placement: sensitive fields often need to move into a separate collection or database that a different group can reach.
- Projection in the source: a separate view or a derived collection can expose only approved fields, if your MongoDB design supports it.
- Exports and previews: check that sensitive fields are not reachable through previews, drill-throughs or downloads of allowed collections.
- Ask your vendor: confirm the column behavior with Metabase before you base an access decision on it.
Record this limitation in your access design so reviewers do not assume a field-level control exists.
Row and column level permissions are part of the paid plans, not the open source edition. According to Metabase's pricing page, row and column level permissions are included in Pro and Enterprise, and are not included in Open Source or Starter. This means a self-hosted instance on the open source edition has no built-in row-level rule for MongoDB, and any isolation must come from separate databases, separate connections or separate instances. Plan cost should be weighed against the data isolation you need, not only against the connection itself.
- Open source limits: the free edition does not provide these permissions, so a shared MongoDB source is visible to every user with access to that connection.
- Starter limits: the Starter plan does not add row or column permissions either.
- Pro and Enterprise: these plans add row-level permissions, which still does not extend to column-level on MongoDB.
- Separate connections: some teams use one connection per tenant or group as a workaround, which adds operational overhead.
- Quote scope: ask for pricing in writing with the number of users and the plan named.
Confirm current plan contents on the pricing page before you commit to a plan.
Isolation on MongoDB is only as strong as the checks you run against it. Build a test matrix that signs in as each group, runs the same questions and compares the returned documents with what the group should see. Because column restrictions are unavailable, include tests that confirm sensitive fields are absent from every allowed question, dashboard, subscription and export. Repeat the tests after any change to collections, groups, permissions or the Metabase version, since each change can alter what a restricted user sees.
- Access matrix: list each group, the collections it may read and the documents it should see.
- Negative tests: attempt queries that should fail or return nothing for restricted users.
- Sensitive field sweep: search saved questions and dashboards for fields that must stay hidden.
- Change control: retest after upgrades, schema changes and permission edits.
- Audit review: use the activity records available on your plan to confirm who queried what.
Ask your security team to confirm the test matrix matches the access decisions recorded for each collection.
Securing the MongoDB connection in Metabase
A Metabase connection to MongoDB is only as narrow as the database user behind it and the people who can change it. The cards below cover the database account, the network path, how credentials are stored, and who inside Metabase can edit the connection.
Create a read-only database user
Give Metabase its own MongoDB user that holds only read roles on the databases and collections it needs to query. Avoid write roles, since Metabase has no need to insert or modify documents to answer questions. Check the granted roles after creation, because a role inherited from a broader group can silently widen access. Ask your DBA to confirm the user cannot run administrative commands.
Scope roles to individual databases
Grant roles per database rather than at the cluster level, so the Metabase user cannot see databases that analysts have no business querying. Review the list of databases Metabase syncs and remove any that are not needed for reporting. Treat a cluster-wide role as a deliberate exception that needs a documented owner.
Understand where credentials are stored
Metabase keeps the database password in its application database, not in the MongoDB server. Encrypt that application database and protect the encryption key Metabase uses for stored secrets, since anyone with both the application database and the key can recover the MongoDB password. Confirm the key is held in your secrets store and not in a file next to the JAR.
Application database docsConnect over TLS only
Enable TLS on the MongoDB deployment and configure Metabase to use it, so credentials and query results do not cross the network in clear text. Use the certificate authority your MongoDB servers present and confirm the certificate chain is trusted by the Metabase host. A connection string copied from a non-TLS example will quietly skip this check, so review every field before saving.
Allowlist the Metabase host
Restrict inbound access on MongoDB to the addresses of the Metabase servers, including each node in a Metabase cluster and any NAT egress address. Block every other source at the network layer rather than relying on database credentials alone. Review the allowlist whenever Metabase is moved, scaled or placed behind a new gateway.
Avoid shared administrator accounts
Do not reuse an existing administrator or application account for Metabase, because that account's rights and password rotation schedule will be tied to analytics. A dedicated account makes the audit trail clear, lets you revoke Metabase access without breaking the application, and keeps the password rotation owner obvious. Ask whoever owns MongoDB access to confirm the account is listed in their access review.
Limit who can edit connection settings
In Metabase, anyone who can change a database connection can redirect it to a different host or user, so restrict the admin role to a small named group. Review that group regularly and record changes to database connections. Without the paid plans, confirm your administrator list is kept current through your own process, since granular controls over database access depend on the plan you choose.
Common MongoDB connection failures in Metabase
This table lists the failures teams most often hit when Metabase connects to MongoDB, with the likely cause and the fix for each. Use it as a first check before changing the connection, because several symptoms look alike but come from different settings.
| Failure | Likely cause | Fix |
|---|---|---|
| Authentication fails with valid credentials | The authentication database is wrong. MongoDB stores users in the database where they were created, which is often admin rather than the database Metabase queries. | Set the authentication database field to the database where the user was created, or confirm the user's home database in MongoDB before retrying. |
| Connection times out | A firewall, security group or network policy blocks the port between the Metabase host and the MongoDB hosts, or the replica set members advertise addresses Metabase cannot reach. | Open the MongoDB port from the Metabase server, and confirm each replica set member's advertised hostname resolves and routes from that server. |
| TLS handshake or certificate errors | Metabase is set to use TLS but the server does not present it, or the server certificate is not trusted by the Metabase host. | Match the TLS setting to the server, and install the certificate authority in the trust store Metabase uses. Confirm the certificate hostname matches the address in the connection. |
| Nested fields show as unexpected types | MongoDB documents do not enforce one type per field, so a field can hold strings in some documents and numbers or objects in others. Metabase infers types from sampled documents. | Review the sampled field types in the table metadata, correct the types Metabase shows where needed, and fix inconsistent data at the source or in a modeled view. |
| Collections are missing from the database list | The Metabase user lacks read roles on those collections, so MongoDB does not reveal them to the connection. | Grant the Metabase user read access on the required databases or collections, then run a sync so Metabase reloads the table list. |
| Schema is stale after collection changes | Metabase reads a schema snapshot and updates it on its sync schedule, so new fields or renamed collections appear late or not at all. | Trigger a manual sync for the database, check the sync schedule in the database settings, and rescan field values if filters look out of date. |
When to model MongoDB data elsewhere first
Model the data in a relational or analytical copy before Metabase reads it whenever the collections are heavily nested, their documents differ in shape, or some fields are too sensitive for every viewer. Metabase can read MongoDB directly, but the topic's data isolation guidance places MongoDB under row-level security only, so there is no column-level restriction to hide a sensitive field from a group that can query the collection. If a salary, health or account identifier sits inside a document, the practical options are to remove it before the data reaches Metabase or to move the data into tables where column permissions can be applied. Confirm the current column behavior against the Metabase data isolation methods guide before you rely on it.
Document shape is the second reason. When one application version writes customer.address as an object and another writes it as a string, or when an optional array appears only for some records, Metabase's table view reflects whatever fields it has sampled. A dashboard that worked last month can break after a release changes a field name, and nobody in the analytics team may know the change happened. A relational copy with defined tables, explicit types and a fixed set of columns gives analysts a contract to build against. The trade-off is a pipeline or replica that someone must own: it has to handle schema drift, late-arriving documents, deletes and backfills, and its failures become a new operational duty.
Decide four things before building the copy. First, who owns the transformation logic and the tables it produces, and how changes to the source schema are reviewed. Second, how fresh the data must be, which determines whether a scheduled batch or a change stream feeds the copy. Third, where the copy lives and which Metabase database connection points to it, so that permissions are applied to tables you control. Fourth, what happens to records removed in the source, since analysts will expect the copy to match production. Ask any partner or internal team to write these decisions into the scope, and ask for the costs of the pipeline, its hosting and its upkeep as separate line items in the quote.
Questions buyers ask about connecting Metabase to MongoDB
Can open source Metabase connect to MongoDB?
Yes. Metabase connects to MongoDB either with separate fields for host, database name, port, username, password and an optional authentication database, or by pasting a connection string. Metabase documents support for MongoDB from the oldest supported version to the latest stable release, so the open source edition is not the constraint. The limits come from what the connection can enforce afterwards, which depends on your plan. Confirm the MongoDB version you run against Metabase's MongoDB documentation before you commit to a design.
Which restrictions can Metabase enforce on MongoDB data?
Metabase's data isolation guidance says MongoDB supports only row-level security, not column-level security. Row-level restrictions can limit which documents a group sees, but they cannot hide individual fields from users who can see the collection. Row and column permissions, along with SSO and usage auditing, are included only in the Pro and Enterprise plans, according to the Metabase pricing page. Plan your access model around that split, and ask whether sensitive fields need to be removed or moved before the data reaches Metabase.
Can column-level restrictions be added to a MongoDB connection?
Not through Metabase itself. Column-level security is not supported for MongoDB in Metabase's data isolation guidance, so no setting in the application will hide specific fields. The practical options are to restrict what the connected database user can read at the MongoDB layer where your platform allows it, to expose only a curated view or separate collection with the approved fields, or to keep sensitive fields out of the analytics path entirely. Each option needs a data owner decision and a test that a restricted user cannot see the excluded field.
What drives the effort and cost of a MongoDB connection?
The cost is mostly the time spent on access design and data modeling, not the connection itself. The main drivers are the number of collections, how inconsistent the document shapes are, how many teams need separate row-level rules, and whether analysts expect joins across collections or SQL-style reporting. Documents with varying fields often need flattening or a reporting layer before dashboards are useful. A quote should list the collections in scope, the permission model, the modeling work, and the testing of each restricted group. Plan terms that include SSO or row-level permissions are listed on the Metabase pricing page.
What does the client need to provide before the work starts?
Expect to provide several things before the connection can be built and tested:
- A read-only MongoDB account for Metabase, with its authentication database and the collections it may read
- Network access from the Metabase host to the MongoDB deployment, including any firewall or private network rules
- Named data owners who can approve which collections, documents and fields analysts may see
- A test environment or sample data set that matches production document shapes
- Access to the Metabase instance and its administrators, so group and permission settings can be applied and checked
Confirm the account and network details with your MongoDB and network teams early, because they often set the pace.
How long does it take to confirm a MongoDB connection works?
It depends on scope and environment. A single connection to a test database with clean collections can be checked quickly, while a production deployment with many collections, network approvals, and separate access rules takes longer. Time is usually spent on network paths, account permissions, and the data owner reviews rather than on the Metabase setting itself. Ask for a plan that lists each verification step, including a check that a restricted user sees only the approved documents, and agree the completion criteria in writing before work starts.
Can our own team connect Metabase to MongoDB without a partner?
Often yes, if you have someone comfortable with MongoDB user administration, Metabase administration and network changes. The connection form itself is straightforward. The risk sits in the decisions around it: which collections to expose, how row-level rules map to document fields, and whether the modeling approach holds as data changes. A partner is useful when those decisions need an outside review or when you want the setup tested against your access model. Consider whether your team can also keep the connection and its rules current after the first release.
When should we model MongoDB data somewhere else first?
Model the data elsewhere first when documents vary widely in shape, when analysts need joins and consistent tables, or when column-level restrictions are required and cannot be met at the database layer. A reporting database or warehouse with curated tables gives Metabase a stable schema, supports the permission model your plan allows, and keeps sensitive fields out of the analytics path. Metabase's permission and data isolation documentation explains how the choice affects access. This is a design decision for your data owners and architects, and it should be made before dashboards are built.
How DeployOpen scopes the Metabase and MongoDB work
DeployOpen starts with a written scope that names the MongoDB databases, collections and users Metabase will read, and the access model that governs them. The work is planned inside your infrastructure, so connection settings, secrets and test data stay under your control from the first day.
How we scope
- Inventory the MongoDB databases and collections Metabase should expose, and the teams that will query them.
- Decide between connection fields and a connection string, and record where credentials will be stored.
- Confirm which row-level filters are needed, since column-level security does not apply to MongoDB in Metabase.
- Agree in writing whether modeling data elsewhere first is part of the work or a separate decision.
How we build
- Create a read-only MongoDB user scoped to the agreed databases, with the authentication database set correctly.
- Configure the connection in a non-production Metabase instance and confirm schema sync and field types look correct.
- Build row-level permission rules for each group and test them with accounts from every group.
- Document each collection exposed, its owner and the sync and scan settings chosen for it.
How we hand over
- Deliver a runbook covering connection settings, credential rotation steps and the database user's privileges.
- Provide a test matrix showing which users see which documents, with results recorded for your review.
- Walk your platform and data teams through the access model so they can add collections safely.
- Record open decisions, such as data that should move to a relational or analytics store, for your review.
How we support
- Fixed-scope engagements have deliverables and timelines agreed in writing before work starts.
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- Re-test row-level rules when new collections, groups or Metabase versions are introduced.
- Confirm MongoDB and Metabase version compatibility with the vendor documentation before each upgrade.

