Lab - Remove and Re-Add a Node problem

Hi all,

I write this post for asking what I have to do in this Lab, because I dont understand well what I have to do. I removed my third node, but then I dont know what I should change. What means exactly this part of the text?:

""In this lab, you will modify the replica set so one of the nodes uses the hostname m103, the virtual machine hostname, instead of the external IP address of the Vagrant box.

To correctly reconfigure this node, you will have to remove the node from the replica set, and then add it back with the correct hostname. For this lab, you only need to do this for one of the nodes in the set.""

Please help me!! Thanks you :smiley:

While logged into the Primary node, you need to remove one of the secondary nodes with rs.remove(), and then simply re-add it with rs.add(), only instead of using the ip address you use m103. Hope this helps!


Thanks you so much, I got it! However I have a question:
when I wrote:

–host m103-repl/

The connection to the server fail. I have to replace “m103-repl/” for “m103-repl/”.

I would like to know why this does not run for me.
Thanks you so much!!

The host name probably do not resolve to the IP address

The command ping may tells you the IP address if any. You may correct it in the file /etc/hosts.

1 Like

Well, I realised that the IP adress is wrong. Do you know how it should be changed?
Thanks you so much!! :smiley:

The file /etc/hosts should be edited. Make sure you sudo to edit the file as it is only writable by root. Personally I use vi so I edit with sudo vi /etc/hosts.

1 Like

This was exactly what I was needing. I rewrote my config files before I realize it was that simple.


can you explain me clearly .
why we need hosts file??

can u tell me how to set ip for m103

We had to do it when I took the course a while back. Not sure if it is needed anymore, you should start a new thread.

in this lab , i added new replica set using rs.add(“m103:27003”) but show error like this .

if i replace m103 with ip address its works fine.

my question is , do u have set ip address for m103 . if it so , how to set ??

Hi @Dhilip_28128,

The m103 hostname maps to ip address, you can check the same using the command below:

ping m103

Otherwise, you can check the /etc/hosts file to view the hostname mapping.

Please let me know, if you have any questions. I would recommend you to share the screenshot of the error, the above ping command and contents of /etc/hosts file in a separate thread to avoid confusion.


in this lab , i added new replica set using rs.add(“m103:27003”) but show error like this .

if i replace m103 with ip address its works fine.

how to complete this task

It looks like m103 is IP and it might be why it fails. It depends on how you started the serer at port 27001. If you started it with it will fails because it does not listen to

it shows same error

Like I wrote your server (now at port 27003) is not listening at IP It might be listening at or You have to listen to the same IP/port as the one you try to talk. If you start your server at then you must connect to but if you start it at you must connect to Same IP and same port number.

Hi @Dhilip_28128,

As per lab requirements, all the nodes should be configured with IP address: .
You will need to update the /etc/hosts file and map m103 with the IP address.
Please check the screenshot of my /etc/hosts file:

Please let me know, if you have any questions.



Like @steevej-1495 and @Sonali_Mamgain have explained, the problem is with the mapping of m103 to in your /etc/hosts file and you need to edit it as follows:

  • Delete (1.)
  • Change (2.) like this:
  • Save and exit the file

@Sonali_Mamgain, for some strange reason this is still happening. As explained here, here and here, the hosts file isn’t mapping correctly and somehow a IP mapping is created exactly like my screenshot. Can you please pass on to your colleagues to investigate fix and in the meantime please add a note to the lectures/labs to avoid any confusion in the future. It will continue to creep up.

PS: This particular lab actually requires using the hostname instead of the IP address


thank you so much for your response .
i had overcome this error

Closing the thread as the issue has been resolved.