[Solution] Incorrect Hostname and IP address mapping in the /etc/hosts file


We have noticed that the m103 and m103.mongodb.university hostnames are not getting mapped to the correct IP address i.e. in the /etc/hosts file in the Vagrant environment.

Due to this, learners are having difficulty in completing the labs when they add a node in the replica set using the hostnames.

For the resolution of the issue, you have to modify this line : m103.mongodb.university m103

You can edit the /etc/hosts/ file using the vim editor. Run this command in the vagrant prompt to open the file.

sudo vim /etc/hosts

This will open the hosts file in your terminal. Now press i and hit enter to enter the insert mode.

Change to in the first line.

Press esc and then,
Press :x and enter to save and exit

After making the change, your /etc/hosts file would look like this.

You can verify the changes by pinging the hostnames.

ping m103

ping m103.mongodb.university

Both the ping results will show

Hope it helps!

Please feel free to get back to us if you have any query.

Shubham Ranjan
Curriculum Services Engineer