My mongodb sharded cluster is set with 1-member replica set for config server with 6 shards, 1 mongos. All these components are hosted on a single server with mongos on and rest on All addresses have been configured through hostnames in /etc/hosts i.e as configrs , as mongos and bindIP in mongo config holds these hostnames and not IP addresses.

I want to host a mongos on separate server. Since config server was hosted on, to make it reachable I stopped the config mongo, updated /etc/hosts contents from configrs to configrs and restarted the config mongo. But now, rs.status() returns

"state" : 10,
"stateStr" : "REMOVED",
"uptime" : 12,
"optime" : { "ts" : Timestamp(1521449062, 2),
"t" : NumberLong(3)
"optimeDate" : ISODate("2018-03-19T08:44:22Z"),
"ok" : 0,
"errmsg" : "Our replica set config is invalid or we are not a member of it",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig"

How do I move my config server from to I went through hostname change documentation for mongo, but it lists down steps to change hostnames whereas I am not changing hostname.

2 Answers 2


Address (itself) don't exists.

It is used at config files as value what means "listen all network devices".

If you want to have mongos at different server, you need to configure your cluster to use address what is connected to network device what point outside world (maybe eth0). All components of that cluster (config server, all shards) must be using that "external" IP-address what is reachable from that machine where you are going to put that mongos.

How to change all components to use external IP address? It is possible to do "under the hood", but to you it would be easier to export all data to HD, rebuild your cluster with right configuration and then import data back to cluster.


You should take a look at the mongodb reference https://docs.mongodb.com/manual/tutorial/change-hostnames-in-a-replica-set/

To summarize, you have to update system.replset collection under local database.

Once config replicaset dbs are back to online, You need to check mongos startup parameter such as "configdb"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.