Mongodb – Unable to add replica set to shard

mongodbmongodb-3.2

I was trying to add a new replica set to my mongodb sharded cluster but I keep getting the following error:

{
    "ok" : 0,
    "errmsg" : "Could not verify that config servers were active and reachable before write",
    "code" : 25
}

I checked all the config servers and they are up and running.The problem is new as I can previously add shards without any issues.

The MongoDB version I am using is 3.2 running on Ubuntu 16.02.

How can I fix this?

Best Answer

Managed to find the error source.

First, check the log file (eg. [Path to log)/mongod.log)

Turns out that the authentication has failed on one of the config servers. This is fixed by including " --auth --keyFile [Path to Key]" when starting up the config server mongod.