# Connection Issue to MongoDB Cluster via Mongo Compass

**URL:** <https://forums.percona.com/t/connection-issue-to-mongodb-cluster-via-mongo-compass/27899>\
**Category:** Percona Everest\
**Tags:** mongodb\
**Created:** [January 19, 2024, 8:38pm UTC](https://forums.percona.com/t/connection-issue-to-mongodb-cluster-via-mongo-compass/27899 "2024-01-19T20:38:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexei\_Fokin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/alexei_fokin/32/13579_2.png) [@Alexei\_Fokin](https://forums.percona.com/u/Alexei_Fokin)\
**Post date:** [January 19, 2024, 8:38pm UTC](https://forums.percona.com/t/connection-issue-to-mongodb-cluster-via-mongo-compass/27899/1 "2024-01-19T20:38:13Z")

</div>

Hello,

I am facing an issue when trying to connect to a MongoDB cluster that I deployed using Percona Everest with external access. When trying to connect via Mongo Compass, I get the following error:

```auto
`getaddrinfo ENOTFOUND mongodb-dev1-rs0-0.mongodb-dev1-rs0.percona-everest.svc.cluster.local`.

```

url connection:  
mongodb://userAdmin:\*\*\*\*\*\*@34.0.0.0:27017,35.0.0.0:27017,35.0.0.0:27017/

---

<div class="post-metadata">

**Author:** ![daniil.bazhenov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/daniil.bazhenov/32/62_2.png) [@daniil.bazhenov](https://forums.percona.com/u/daniil.bazhenov)\
**Post date:** [January 22, 2024, 11:13am UTC](https://forums.percona.com/t/connection-issue-to-mongodb-cluster-via-mongo-compass/27899/2 "2024-01-22T11:13:09Z")

</div>

Hi, I have not been able to connect using MongoDB Compass either. I have forwarded this information to my colleagues in the Percona Everest team.

At the moment I’ve been using documentation from Percona Operators to make the connection

> **[Percona Operator for MongoDB - Connect to Percona Server for MongoDB](https://docs.percona.com/percona-operator-for-mongodb/connect.html)**
>
> In this tutorial, you will connect to the Percona Server for MongoDB cluster you deployed previously.

Run a container with a MongoDB client and connect its console output to your terminal:

```auto
kubectl -n percona-everest run -i --rm --tty percona-client --image=percona/percona-server-mongodb:6.0.9-7 --restart=Never -- bash -il

```

Connecting using mongosh

```auto
mongosh "mongodb://userAdmin: **** @host:27017,host:27017,host:27017/admin?ssl=false"

```

 ![Screenshot 2024-01-22 at 3.12.41 PM](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/a/aae02c488b6820cc535696a03f8a2f0de003bee4.png)

---

<div class="post-metadata">

**Author:** ![daniil.bazhenov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/daniil.bazhenov/32/62_2.png) [@daniil.bazhenov](https://forums.percona.com/u/daniil.bazhenov)\
**Post date:** [January 22, 2024, 2:31pm UTC](https://forums.percona.com/t/connection-issue-to-mongodb-cluster-via-mongo-compass/27899/3 "2024-01-22T14:31:25Z")

</div>

I’ve been told that connecting using MongoDB Compas is so far only available when creating a cluster using Percona Operator directly, with the parameter

```auto
spec:
  clusterServiceDNSMode: "External"

```

also the connection will be available with the Direct Connection parameter

 ![Screenshot 2024-01-22 at 6.30.37 PM](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/b/ba0d85efaa2300cf24e2b9f23733cb6ff1185fc2.png)

However, this cannot be done now with a cluster created in Percona Everest.

We have created a task in Jira to add this in future versions.

---

<div class="post-metadata">

**Author:** ![Alexei\_Fokin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/alexei_fokin/32/13579_2.png) [@Alexei\_Fokin](https://forums.percona.com/u/Alexei_Fokin)\
**Post date:** [January 22, 2024, 2:34pm UTC](https://forums.percona.com/t/connection-issue-to-mongodb-cluster-via-mongo-compass/27899/4 "2024-01-22T14:34:23Z")

</div>

Yes. I’m working with an operator. Uh, thank you.

---

<div class="post-metadata">

**Author:** ![daniil.bazhenov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/daniil.bazhenov/32/62_2.png) [@daniil.bazhenov](https://forums.percona.com/u/daniil.bazhenov)\
**Post date:** [January 22, 2024, 2:37pm UTC](https://forums.percona.com/t/connection-issue-to-mongodb-cluster-via-mongo-compass/27899/5 "2024-01-22T14:37:44Z")

</div>

Yes, @Slava_Sarzhan helped me with this today, he often helps on the forum, so if there are any questions, we’ll try to help.

---

<div class="post-metadata">

**Author:** ![daniil.bazhenov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/daniil.bazhenov/32/62_2.png) [@daniil.bazhenov](https://forums.percona.com/u/daniil.bazhenov)\
**Post date:** [January 24, 2024, 10:16am UTC](https://forums.percona.com/t/connection-issue-to-mongodb-cluster-via-mongo-compass/27899/6 "2024-01-24T10:16:17Z")

</div>

I was able to connect using MongoDB Compass.

I used a single host in the path and Direct Connection mode.

If one node, it’s easy, but if you have multiple nodes, you need to define Primary.

I used PMM and the ReplicaSet Summary dashboard since so far Everest doesn’t show the status of nodes, but as far as I know this is planned to be added.

 ![Screenshot 2024-01-24 at 2.14.15 PM](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/2/2c20b69100417edbfb23703bdcfbc903f39833b1.png)  
 ![Screenshot 2024-01-24 at 2.00.20 PM](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/c/ccccd741f2aeb4eb7f479f922779274e17b717fc.png)  
 ![Screenshot 2024-01-24 at 2.09.13 PM](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/9/9fa054e1e292ef79a8f120407e63d3790b2b53b9.png)

---

<div class="post-metadata">

**Author:** ![daniil.bazhenov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/daniil.bazhenov/32/62_2.png) [@daniil.bazhenov](https://forums.percona.com/u/daniil.bazhenov)\
**Post date:** [January 24, 2024, 10:46am UTC](https://forums.percona.com/t/connection-issue-to-mongodb-cluster-via-mongo-compass/27899/7 "2024-01-24T10:46:53Z")

</div>

A note for the future. How to connect in detail step by step for beginners.

Currently, the Percona Everest interface for a MongoDB cluster with External Access enabled displays the IPs of the hosts to connect to. I believe that we will fix it in the future, it’s about the current moment.

 ![Screenshot 2024-01-24 at 2.37.08 PM](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/d/dd724b290e874eba4ad1d43f9f26f692081718ee.png)

To connect using MongoDB Compass we need a Primary replica, but we don’t know which IP leads to the Primary at the moment.

We can get a list of k8s services, and find out the matching IPs and replica names.

```auto
kubectl -n percona-everest get services

```

 ![Screenshot 2024-01-24 at 2.39.43 PM](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/8/869b0726857ff0f13ef2b612524e00b628111f36.png)

Next, we can use mongosh to connect to the cluster:

```auto
mongosh "mongodb://databaseAdmin: ****** @host:27017,host2:27017,host3:27017/admin?ssl=false"

```

And find out which replica is Primary with the command:

```auto
rs.status()

```

Or a shortened version of the output

```auto
rs.status().members.forEach(function(member) {printjson({name: member.name, status: member.stateStr})})

```

Output:

```auto
rs0 [primary] admin> rs.status().members.forEach(function(member) {printjson({name: member.name, status: member.stateStr})})
{
  name: 'mongodb-bmq-rs0-0.mongodb-bmq-rs0.percona-everest.svc.cluster.local:27017',
  status: 'SECONDARY'
}
{
  name: 'mongodb-bmq-rs0-1.mongodb-bmq-rs0.percona-everest.svc.cluster.local:27017',
  status: 'PRIMARY'
}
{
  name: 'mongodb-bmq-rs0-2.mongodb-bmq-rs0.percona-everest.svc.cluster.local:27017',
  status: 'SECONDARY'
}

```

Here we already understand which replica is Primary (mongodb-bmq-rs0-1) and use its Service IP to connect to MongoDB Compass.

 ![Screenshot 2024-01-24 at 2.45.32 PM](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/5/51f3d0b861141acc0fde0a5d41b22e25819c3d58.png)  
 ![Screenshot 2024-01-24 at 2.45.15 PM](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/f/fb286d671443a3ef5dd453ef8b272850af6f8e3b.png)
