# Connect to a MongoDB Instance

This topic explains how to connect to your MongoDB instance using `mongosh`.

A list of all MongoDB clusters is displayed.

2\. Select a cluster from the list by clicking on its name. Alternatively, click **Details** in the **OPTIONS** column.

3\. On the **MongoDB Cluster overview** page, navigate to the **Cluster details** tab and copy the cluster's **Connection URI**.

![View the details of a MongoDB cluster](/files/eku3F63PKIcuuEMtRnpt)

4\. Open your terminal and run the following command:

```bash
mongosh -u <yourUsername> -p <yourPassword> "<your-Connection-URI>"
```

Replace the following:

* `<yourUsername>` with your database username.
* `<yourPassword>` with your password.
* `<your-Connection-URI>` with the **Connection URI** you copied from the DCD.

{% hint style="success" %}
**Result:** You see the database is accepting connections.
{% endhint %}

Here is an example of a MongoDB shell connection:

![Connect to a MongoDB instance via Shell Connection](/files/QlcSG3dgQfvTylIXkelh)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ionos.com/cloud/databases/mongodb/api/v1-api/connect-to-mongodb-instance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
