> AI agents: this is one page from Mammoth Analytics documentation. The index of all pages as Markdown is https://mammoth.io/docs/llms.txt. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get Markdown.

# Connect MongoDB or MongoDB Atlas to Mammoth

> Connect Mammoth to MongoDB or MongoDB Atlas, pick a collection and the fields you want, and save the documents as rows in a dataset that refreshes.

The MongoDB connector imports documents from a MongoDB collection into Mammoth as rows in a dataset. Open it from **Data Library** > **New dataset** > **Connectors** and search for **MongoDB**. Project Admins create the connection; Project Editors can start datasets from a connection the project already has. Which connectors you can add depends on your plan.

## What you can bring in from MongoDB

- The documents in any collection the user can read, one row per document.
- Only the fields you tick.

MongoDB has collections only, so the workspace has no SQL query view for it. AI query writing isn't available for MongoDB.

## Before you connect MongoDB

You need:

- A MongoDB instance reachable from the internet, such as a MongoDB Atlas cluster.
- A MongoDB user with the `read` role on the database you want to import from.
- The server's hostname, port (default `27017`), database name, username and password.
- Mammoth's IP address added to your MongoDB network allowlist. See [Allow Mammoth through your firewall](https://mammoth.io/docs/learn/get-data-in/network-requirements/).

### Find your MongoDB Atlas hostname

In Atlas, go to **Atlas → Database → Connect → Connect your application**. The hostname looks like `cluster0.abc123.mongodb.net`. Enter it in **Host URL** with the `mongodb+srv://` prefix, for example `mongodb+srv://cluster0.abc123.mongodb.net`. Mammoth turns on TLS only when **Host URL** starts with `mongodb+srv://`, and Atlas requires TLS. Add Mammoth's IP address to your Atlas **Network Access** allowlist.

## Connect MongoDB to Mammoth

1. Go to the **Data Library**, click **New dataset**, and choose **Connectors**.
2. Search for **MongoDB** and click its tile. The connection form opens.
3. Fill in the fields below and click **Connect**. If the check fails, the error appears at the bottom of the form.
4. Once Mammoth has connected, the connector workspace opens on your collections. See [Connect a database or app](https://mammoth.io/docs/learn/get-data-in/connect-a-source/) for the shared steps.

![MongoDB New Connection form with Host URL, Port 27017, Username, Password, Database, and Display Name fields](https://mammoth.io/docs/images/20260615_102934_Screenshot2026-05-211505091.webp)

| Field | What to enter | Example |
| --- | --- | --- |
| **Host URL** | Hostname or IP address of your MongoDB server | `mongo.example.com` |
| **Port** | TCP port MongoDB listens on | `27017` (default) |
| **Username** | MongoDB user with read access | `mammoth_reader` |
| **Password** | Password for the user | |
| **Database** | Name of the MongoDB database. Mammoth also signs the user in against this database | `analytics` |
| **Display Name** | Optional label for this connection | `MongoDB Atlas` |

## Pick MongoDB collections and fields

1. In **Tables**, click a collection to see its fields and sample rows.
2. Tick the fields you want. They gather in **Your table**.
3. Click **Preview 100 rows** to check the result.

![MongoDB New Dataset dialog with collection list, SELECT query, preview of three rows, and Dataset saved message](https://mammoth.io/docs/images/20260615_102954_Screenshot2026-05-211511351.webp)


## Save MongoDB data as a dataset

1. Click **Save as dataset**.
2. Enter a **Dataset name** and pick the folder under **Save in**.
3. Under **Keep it up to date**, choose **Daily** or **Manual**.
4. Click **Save**.

![MongoDB New Dataset dialog with Save table as, Update Method, and Save as dataset button below the preview](https://mammoth.io/docs/images/20260615_103011_Screenshot2026-05-211512401.webp)


## Refresh MongoDB data and choose an update method

Choosing **Daily** creates a [Dataset Refresh](https://mammoth.io/docs/learn/automate/refresh-a-dataset/) automation that you can reschedule later.

After the dataset is saved, its **Update method** offers these options:

| Update method | What it does |
| --- | --- |
| **Replace all data** | Rebuilds the dataset from the source on every refresh |
| **Add new rows only** | Keeps your rows and adds rows above the last value of a **Key column** |
| **Keep only the newest rows** | Empties the dataset, then brings in rows since the last refresh (needs a **Key column**) |

A key column is a numeric or date column whose values only go up, such as an ID or a date.

## Troubleshoot MongoDB connections

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Connection fails | Port 27017 is closed to Mammoth | Open port 27017 inbound from Mammoth's IP address |
| Connection fails on Atlas | Mammoth isn't on the Atlas allowlist | Check your **Network Access** list in the Atlas console |
| Connection fails on Atlas | **Host URL** has no `mongodb+srv://` prefix, so TLS is off | Enter the host as `mongodb+srv://cluster0.abc123.mongodb.net` |
| Connection fails or no collections | The user lacks the `read` role | Run `db.grantRolesToUser("mammoth_reader", [{ role: "read", db: "analytics" }])` |

## Related

- [Connect a database or app](https://mammoth.io/docs/learn/get-data-in/connect-a-source/): the shared connector workspace steps.
- [Allow Mammoth through your firewall](https://mammoth.io/docs/learn/get-data-in/network-requirements/): the IP address to allow.
- [Manage saved connections](https://mammoth.io/docs/learn/get-data-in/connections/): edit, reuse or delete this connection.
- [Refresh a dataset](https://mammoth.io/docs/learn/automate/refresh-a-dataset/): change when the dataset refreshes.
- [Connector reference](https://mammoth.io/docs/learn/get-data-in/connectors/): every source Mammoth connects to.

---
Source: https://mammoth.io/docs/learn/get-data-in/connectors/mongodb.md · Updated: 2026-11-08
