> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Linking MongoDB as a source Canonical URL: https://posthog.com/docs/data-pipelines/sources/mongodb > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.posthog.com` instead of `https://app.posthog.com` (app host for links). ## On this page - [Configuration](#configuration) - [Supported tables](#supported-tables) - [Troubleshooting](#troubleshooting) ![](https://res.cloudinary.com/dmukukwp6/image/upload/texture_tan_9608fcca70) ![](https://res.cloudinary.com/dmukukwp6/image/upload/texture_tan_dark_a92b0e022d) Let AI connect your sources for you Skip the manual setup — run this in your project and the wizard auto-detects your databases and APIs and connects them to PostHog. `npx @posthog/wizard warehouse` ![PostHog Wizard hedgehog](https://res.cloudinary.com/dmukukwp6/image/upload/wizard_3f8bb7a240.png) ![](https://res.cloudinary.com/dmukukwp6/image/upload/wizard_3f8bb7a240.png)Let AI connect your sources for you The MongoDB connector can link your MongoDB collections to PostHog. To link MongoDB: 1. Go to the [Data pipeline page](https://app.posthog.com/data-management/sources) and the sources tab in PostHog 2. Click **New source** and select MongoDB 3. Enter your MongoDB connection string. If your connection string doesn't include a database name, enter it in the optional **Database name** field. 4. Click **Next**, select the collections you want to sync, as well as the [sync method](https://posthog.com/docs/data-pipelines/sources.md#incremental-vs-full-table), and then press **Import** > **Tip:** MongoDB Atlas SRV connection strings usually omit the database name (e.g., `mongodb+srv://user:pass@cluster.mongodb.net/`). If yours doesn't include one, fill in the **Database name** field. A database specified in the connection string (e.g., `mongodb+srv://user:pass@cluster.mongodb.net/my_database`) takes precedence over this field. Once the syncs are complete, you can start using MongoDB data in PostHog. > **Note:** MongoDB data is unstructured so the returned columns are an `_id` field and a `data` column that contain the entire document contents. Data fields can be selected with dot notation (e.g. `data.field1`) ## Configuration | Option | Description | | --- | --- | | `Connection string` **Type:** password **Required:** True | In MongoDB Atlas, open your cluster and click **Connect → Drivers** to copy this, then replace `` with your database user's password. Self-hosted clusters use the host and port form in the placeholder, keeping `tls=true`. | | `Database name` **Type:** text **Required:** False | Only needed if your connection string doesn't already include the database (Atlas `mongodb+srv://...` strings usually don't). | ## Supported tables The tables available from this source are discovered from your account when you connect it, so the exact list depends on your data. Once connected, you can pick which tables to sync from the [sources tab](https://app.posthog.com/data-management/sources). ### Incremental and append-only syncing MongoDB supports incremental and append-only sync methods. For a field to be available for these sync methods, it must: 1. **Have an index** — only indexed fields are eligible. 2. **Be a supported type** — the following BSON types work: - `date` or `timestamp` - `int` or `long` - `double` or `decimal` - `objectId` (only for the `_id` field) PostHog infers field types from the first 10,000 documents in the collection, so fields with mixed types may resolve to an unsupported type. ## Troubleshooting ### No collections found PostHog connected to MongoDB but reports no collections in the selected database. This usually means one of the following: - **Wrong database in connection string** – A connection string ending in `/admin` or `/test` connects to an empty system database. Update it to point to the database that holds your data. - **Database name not specified** – Atlas `mongodb+srv://` strings often omit the database name. Set the **Database name** field in PostHog to the correct database. - **Missing read permissions** – Collection listing is filtered by authorization. Ensure your database user has a read role (such as `read` or `readAnyDatabase`) on the target database. #### Inbound IP addresses We use a set of IP addresses to access your instance. To ensure this connector works, add these IPs to your inbound security rules: | US | EU | | --- | --- | | 44.205.89.55 | 3.75.65.221 | | 52.4.194.122 | 18.197.246.42 | | 44.208.188.173 | 3.120.223.253 |