# Error establishing direct connection to mongo node Error output: no reachable servers

**URL:** <https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [August 31, 2022, 9:41pm UTC](https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395 "2022-08-31T21:41:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asher\_Manangan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asher_manangan/32/110318_2.png) [@Asher\_Manangan](https://discuss.elastic.co/u/Asher_Manangan)\
**Post date:** [August 31, 2022, 9:41pm UTC](https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395/1 "2022-08-31T21:41:27Z")

</div>

Hi,

**Here is the log:**

```auto
 Error establishing direct connection to mongo node at [127.0.0.1:27017]. Error output: no reachable servers

```

I tried a lot of things, but after so many days, I can't find it work.

**Here is my mongodb.yml configuration**

```auto

# Module: mongodb
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.10/metricbeat-module-mongodb.html

- module: mongodb
  metricsets:
    - dbstats
   # - status
   # - collstats
   # - metrics
   # - replstatus
  period: 10s

  # The hosts must be passed as MongoDB URLs in the format:
  # [mongodb://][user:pass@]host[:port].
  # The username and password can also be set using the respective configuration
  # options. The credentials in the URL take precedence over the username and
  # password configuration options.
  hosts:
   - "mongodb://127.0.0.1:27017"

```

It doesn't have a password. I verified it by running on local and also remote.

The /etc/mongod.conf bind IP is set to 0.0.0.0. I verified that it can connect outside using this command.

```auto
mongosh mongodb://18.191.206.XXX:27017

```

I am using MongoDB version 4, I tried using MongoDB version6 but it doesn't work as well.

My Metricbeat Version is OSS 7.2

Here is the fulll error log:

```auto
2022-08-31T21:40:21.476Z INFO [esclientleg] eslegclient/connection.go:314 Attempting to connect to Elasticsearch version 7.10.2
2022-08-31T21:40:21.478Z INFO template/load.go:97 Template metricbeat-7.10.2 already exists and will not be overwritten.
2022-08-31T21:40:21.479Z INFO [index-management] idxmgmt/std.go:298 Loaded index template.
2022-08-31T21:40:21.480Z INFO [publisher_pipeline_output] pipeline/output.go:151 Connection to backoff(elasticsearch(https://elastic-wazuh.dts-nonprod.ardentcloud.com:9200)) established
2022-08-31T21:40:30.451Z ERROR mongodb/mongodb.go:98 Error establishing direct connection to mongo node at [127.0.0.1:27017]. Error output: no reachable servers
2022-08-31T21:40:30.451Z INFO module/wrapper.go:259 Error fetching data for metricset mongodb.dbstats: error creating new Session: no reachable servers

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 31, 2022, 9:41pm UTC](https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395/2 "2022-08-31T21:41:27Z")

</div>

Elasticsearch version 7.10 is [EOL](https://www.elastic.co/support/eol) and no longer supported. Please upgrade ASAP.

(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns :elasticheart: )

---

<div class="post-metadata">

**Author:** ![MichelLaterman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michellaterman/32/110221_2.png) [@MichelLaterman](https://discuss.elastic.co/u/MichelLaterman)\
**Post date:** [September 1, 2022, 7:31pm UTC](https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395/3 "2022-09-01T19:31:00Z")

</div>

is metricbeat running on the same host? The error message indicates nothing is running.  
Does providing the remote other IP address work?

---

<div class="post-metadata">

**Author:** ![Asher\_Manangan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asher_manangan/32/110318_2.png) [@Asher\_Manangan](https://discuss.elastic.co/u/Asher_Manangan)\
**Post date:** [September 2, 2022, 1:52am UTC](https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395/4 "2022-09-02T01:52:13Z")

</div>

Yes the **metricbeat** is running on the same host.

 ![1](https://us1.discourse-cdn.com/elastic/original/3X/b/7/b71fc506721564a1a89507f4b600ce920085e0c8.png)

The mongodb is also running on the same host.

 ![mongod](https://us1.discourse-cdn.com/elastic/original/3X/5/9/59c1c0a7337ef3e7d7118afcfe3fff86202e8c01.png)

Providing the more IP address doesn't work.

 ![fulllog](https://us1.discourse-cdn.com/elastic/original/3X/7/2/72581773685d95e2fe9d0808c5e462e65f37037e.png)

Accessing the mongodb locally and remotely does work, I tried testing it via mongosh.

---

<div class="post-metadata">

**Author:** ![lalits](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lalits/32/107097_2.png) [@lalits](https://discuss.elastic.co/u/lalits)\
**Post date:** [September 7, 2022, 9:58am UTC](https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395/5 "2022-09-07T09:58:09Z")

</div>

Are you able to run mongosh on the localhost also?

Also, Is it possible for you to upgrade the stack and see if this issue is only for older version.

---

<div class="post-metadata">

**Author:** ![Asher\_Manangan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asher_manangan/32/110318_2.png) [@Asher\_Manangan](https://discuss.elastic.co/u/Asher_Manangan)\
**Post date:** [September 7, 2022, 11:57am UTC](https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395/6 "2022-09-07T11:57:14Z")

</div>

Hi I've tried using a new instance and set up mongodb version 4.2, it does work now.

---

<div class="post-metadata">

**Author:** ![lalits](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lalits/32/107097_2.png) [@lalits](https://discuss.elastic.co/u/lalits)\
**Post date:** [September 7, 2022, 12:09pm UTC](https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395/7 "2022-09-07T12:09:00Z")

</div>

👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 5, 2022, 2:09pm UTC](https://discuss.elastic.co/t/error-establishing-direct-connection-to-mongo-node-error-output-no-reachable-servers/313395/8 "2022-10-05T14:09:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
