GameMaster2030
GameMaster2030

Reputation: 11

MongoDB: No host described in new configuration 1 for replica set [name] maps to this node

MongoDB is throwing this error at me and I have no idea why. The DNS is correct and as you can see in my rs.initiate config I put the same domain as I'm currently connected to. I also tried using the IP but that didn't work either.

root@vm326877:~/docker/mongo# mongo 01.mongodb.REDACTED.nl --tls --authenticationDatabase admin -u admin -p
MongoDB shell version v4.2.2
Enter password: 
connecting to: mongodb://01.mongodb.REDACTED.nl:27017/test?authSource=admin&compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("b89142ed-1f8f-416c-84ec-ccd9303b2c08") }
MongoDB server version: 4.2.2
Server has startup warnings: 
2020-01-01T17:15:12.401+0100 I  STORAGE  [initandlisten] 
2020-01-01T17:15:12.401+0100 I  STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-01-01T17:15:12.401+0100 I  STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

> rs.initiate( {
...    _id : "REDACTED",
...    members: [
...       { _id: 0, host: "01.mongodb.REDACTED.nl:27017" },
...       { _id: 1, host: "02.mongodb.REDACTED.nl:27017" }
...    ]
... })
{
        "ok" : 0,
        "errmsg" : "No host described in new configuration 1 for replica set REDACTED maps to this node",
        "code" : 93,
        "codeName" : "InvalidReplicaSetConfig"
}
> 

Upvotes: 0

Views: 1942

Answers (1)

polo-language
polo-language

Reputation: 846

This can happen if the Common Name (CN) on the instance's certificate doesn't match the host field in the members array. You may have a certificate like this:

[me@myhost somedir]$ openssl x509 -in /path/to/ssl/certs/mongodb.pem -text
Certificate:
    Data:
        ...
        Issuer: ...
        Validity
            ...
        Subject: C = AB, O = CD, OU = EF, CN = some.other.host.org
        Subject Public Key Info:
            ...

While the address used in the members array is matching the configured host:

MongoDB > db.adminCommand({ getCmdLineOpts: 1 }).parsed.net.bindIp
the.actual.host.org

The resolution in this situation is to get a new certificate with the correct hostname for the instance.

Upvotes: 1

Related Questions