Question on on removing/adding a replica node

So i was able to do the lab easy enough. But i have a question and I dunno if I’m giving anything away here. My question is. So if I remove the the node from the set, if I change the IP address in the config file to listen on the host name.
bindAddress: m103
Keeping the socket the same, it will just hang on startup and complain in the logs that the address is already in use even though doing a netstat reveals that the port is not in use. When it is in this state the only way to bring the mongod down is with a kill -9.
So the first question is, why does it hang like this?
The second is, can I have my mongo config file such that it is configured to listen on the host’s name? The lab is an incomplete solution. I got it correct as far as the validate script goes, the replica set says one of the members is on m103, but the actual mongod daemon’s config file is an IP address. So in the real world if m103 changed (i.e. the IP address assigned to the node via DHCP) it would not work. So looking for a clearly understanding on this.

Hi Carl_59373,

It was mentioned in the Lab that “you don’t need to change your configuration file”. Just remove the node and add back again using hostname like:


I hope it clears!


I did see that in the lab instructions and I was able to reconfig get things going and complete the lab. my questions are
why does it hang using a name in the config instead of an IP address?
why would you not want to change the config file, as it stands you are listening on a hard coded IP address, the purpose of the lab is that your server does not have a static IP. So if the server changes it’s IP you have to change the config file to match the IP. So just trying to have a deeper understanding of what is going on here.


It’s going to hang without specifying a port. Can you share your specific bindIp setting so I can give a more detailed answer?

In regards to your second question, you would want to use a config file, but the replication configuration is stored as metadata, hence the rs.add command.

I answered my own question.
So here’s what the problem is.
in the vagrant we are provided m103 resolves to “”
In the lab they wanted us to change from to m103.
which is a bogus setup really for this example.
So in my config file. changing the bind ip from,
Those 2 are the same IP address, mongod is treating these serially. So it starts on one of them, then it tries to do it on the other and the address is already taken as they are both trying to use the same IP and port.

To the powers that be, you should update your vagrant for this class so that m103 resolves to Real world you would update your config file if you are trying to accomplish what is in the lab.