---
title: "Connect MongoDB to Rig — Rig guide"
description: "Connect MongoDB or MongoDB Atlas to Rig with a connection string. Mirror a database's collections into your warehouse, with nested arrays as child tables."
canonical: "https://rig.so/guides/connect-mongodb"
format: markdown
---

Search guides, references, playbooks…⌘K

Browse guides

# Connect MongoDB to Rig

Mirror the collections of a MongoDB database, on Atlas or self-hosted, into your warehouse. Each collection becomes a table, and nested arrays land as child tables. Rig connects with a connection string and a read-only user.

## Before you start

- Create a database user with read-only access. The role on that user is what limits what Rig can read.
- On Atlas, add Rig's IP address to Network Access: `54.76.207.130`, or `35.153.75.215` for US workspaces.
- A self-hosted server needs a public address. Rig never connects to private ones, and certificate checks cannot be turned off.

## Step 1: Prepare your MongoDB connection

1. Create a read-only database user for Rig.
2. On Atlas, go to `Database & Network Access` then `IP Access List` and add the Rig IP address that matches your workspace.
3. Get the connection string. On Atlas, use `Connect` then `Drivers`. It looks like `mongodb+srv://user:password@cluster.example.mongodb.net/?authSource=admin`.
4. Percent-encode any special characters in the password.

Use a read-only user
The Collections field only limits what Rig lists. The user's role is the actual boundary on what can be read.

## Step 2: Connect it in Rig

New to Rig? Watch how to find Connections

Adding a source needs a workspace owner, or a role with the Manage connections permission, on a workspace where you manage your own connections. If the Connectors tab says “Data ingestion for this workspace is managed by Rig”, ask an owner or Rig support to add the source.

1. In Rig, open `Connections`, choose the `Connectors` tab and go to `Sources & actions`.
2. Search for **MongoDB / MongoDB Atlas**, open the card and click `Connect`.
3. **Connection string**: paste the full `mongodb://` or `mongodb+srv://` string, with the read-only user's credentials.
4. **Database**: the database to mirror, such as `app`.
5. **Collections**: leave it blank to offer every collection, or list names such as `users,orders` to limit what Rig lists and syncs.
6. Click `Continue`. Rig checks the credentials and lists the streams it can reach, so choose the ones you want and click `Connect`.
7. The source then syncs on its schedule, which is nightly unless you change it. To load data straight away, click `Sync` on its row; `Test` pulls a small sample first if you want to check the connection.

## What Rig pulls in

MongoDB lands in its own `mongodb` schema in your warehouse:

- **One table per collection**: the collections come from your own database, so the tables depend on what it holds.
- **Child tables**: nested arrays land as child tables.

Collections with an updated-at field sync edits as well as new documents. Append-only collections sync new documents by `_id`. Rig picks the mode per collection and shows it when you choose collections.

## Good to know

- Reads go to a secondary when the cluster has one, so a sync does not load the primary. A `readPreference` in your connection string is honoured.
- Connections use TLS. `mongodb+srv://` always does, and a plain `mongodb://` server can opt out with `tls=false` only if it is on a public address.
- Edit tracking needs an indexed updated-at field whose values are all dates. Collections without one use a different read mode.
- To disconnect MongoDB, click the bin icon on the source's row under `Sources & actions`. Only whoever connected the source or a workspace owner can do this, and data already synced stays in the warehouse.

## What people use this for

- Analyse application data without querying production
- Flatten nested documents into queryable tables
- Join application data to CRM and billing

[More ideas for using MongoDB](https://rig.so/integrations/mongodb)

## MongoDB documentation

- [Connect to an Atlas cluster](https://www.mongodb.com/docs/atlas/connect-to-database-deployment/)
- [Configure IP access list entries](https://www.mongodb.com/docs/atlas/security/ip-access-list/)

Was this guide helpful?

Yes No

---

- [This page as HTML](https://rig.so/guides/connect-mongodb)
- [Site map for language models](https://rig.so/llms.txt)
- [API and agent documentation](https://rig.so/developers)
