---
title: How to connect an existing MongoDB® Database Instance to a Private Network
description: Instructions for connecting your MongoDB® Database Instance over a Private Network.
tags: managed-mongodb mongodb private-network database-instance
dates:
  validation: 2025-08-25
  posted: 2025-02-17
---
import SshBastionMdb from '@macros/databases/ssh-bastion-mdb.mdx'
import Requirements from '@macros/iam/requirements.mdx'
import VPCRoutingCompatibility from '@macros/vpc/vpc-routing-compatibility.mdx'

[Private Networks](/vpc/concepts/#private-networks) allows you to enhance the security of your system's architecture by isolating it from the internet.

Using Private Networks improves performance by reducing the latency between your application and your database nodes. It also increases the security of your databases, as Instances in your Private Network can directly communicate with your Database Instance, without passing through the public internet.

You can [create new Database Instances](/managed-mongodb-databases/how-to/create-a-database-instance) to attach to your Private Network, or attach existing ones.

<VPCRoutingCompatibility />

<Requirements />

- A Scaleway account logged into the [console](https://console.scaleway.com)
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- A valid [API key](/iam/how-to/create-api-keys/)
- A [Managed MongoDB® Database Instance](/managed-mongodb-databases/how-to/create-a-database-instance)

## How to attach a Database Instance to a Private Network

<Message type="note">
  You can only attach your Database Instance to one Private Network at a time.
</Message>

1. Click **MongoDB®** under **Databases** on the side menu. A list of your Database Instances displays.
2. Click the database name or <Icon name="more" />, then click **More info** to access the Database Instance information page.
3. Scroll to the **Network** section.
4. Click **Attach Private Network** next to **Private endpoint**. A pop-up appears.
5. Choose one or both of the options below:
    - Select and attach an existing Private Network and select the network from the drop-down list.
        <Message type="important">
          The Database Instance must be attached to a Private Network in the same region.
        </Message>
    - Create and attach a new Private Network and enter the name of the network in the form.
        <Message type="important">
          If you select this option, a Private Network with default settings will be created in the same region as your Database Instance. Do not use a TLD (e.g. `dev` or `cloud`) as a name, to avoid conflicts.
        </Message>
6. Click **Attach to Private Network** to conclude.

<Message type="tip">
Once you have attached your Database Instance to a Private Network, you can [connect to the Database Instance](/managed-mongodb-databases/how-to/connect-database-instance) using the private endpoint connection string.
</Message>

## How to connect to a Database Instance through a Public Gateway

<SshBastionMdb />

## How to detach a Database Instance from a Private Network

1. Click **MongoDB®** under **Databases** on the side menu. A list of your Database Instances displays.
2. Click the database name or <Icon name="more" />, then click **More info** to access the Database Instance information page.
3. Scroll to the **Network** section.
4. Click **Detach Private Network**. A pop-up appears.
5. Click **Detach resource** to confirm.

<Message type="note">
This action takes a few moments to complete. During this time, your Database Instance:
  - remains available,
  - goes into **Configuring** mode, and
  - network configuration actions become unavailable
</Message>