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


Here is the log:

 Error establishing direct connection to mongo node at []. 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

# Module: mongodb
# Docs:

- module: mongodb
    - 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.
   - "mongodb://"

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 I verified that it can connect outside using this command.

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:

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( established
2022-08-31T21:40:30.451Z        ERROR   mongodb/mongodb.go:98   Error establishing direct connection to mongo node at []. 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

Elasticsearch version 7.10 is 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: )

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

Yes the metricbeat is running on the same host.

The mongodb is also running on the same host.

Providing the more IP address doesn't work.

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

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.

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


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