Shards error msg “can't use localhost … either use localhost or ipadresses” I'm trying to set up a a test environment on my pc including sharding. I've added 2 shardservers, a configsvr and a router instance. When i'm trying to add a shard I get following errormsg: "Can't use localhost as a shard since all shards need to communicate. Either use all shards and configdbs in localhost or all in actual IPs. host: localhost:27017 isLocalHost:1"" 

I searched online and I found a few topics about it but nowhere they explain how exactly and since I'm new to mongoDB it's quiet hard to understand what's going on. I looked here for example. But since I never used anything else than localhost I find it pretty weird.

This is how I set up:

2 shardsvr instances:

    mongod --shardsvr --replSet rs1 --port 27017 --dbpath D:\data\db
    mongod --shardsvr --replSet rs2 --port 27018 --dbpath D:\data2\db


1 configsvr instance:

    mongod --configsvr --replSet rs0 --port 27019 --dbpath D:\datacfg\db


I initialised the 3 replica sets (another question, do they need to be all different replicasets? or not?).

Then I added a mongos instance:

    mongos --configdb rs0/localhost:27019 --port 27020


And then when I'm trying to connect to mongos &amp; addshards it goes wrong:

    mongo --port 27020




Since I'm never specifying a host I assume that he always uses localhost? no? I don't know how to check anyway. If you need more info tell me.

Thanks in advance
Yes, you cannot mix IP addresses and localhost. Those started mongod processes are now using your network device ip-address. If you don't know your machines ip-address, you can check address with ifconfig or ip address command.

Then if you connect mongos using that ip-address instead of localhost. Remember check that your firewall have all those ports open!