MongoDB Replication – “Failed with No route to host”

centos-7mongodbNetworkreplication

Hi,

Running MongoDB version 3.4.9 on two separate servers running Centos 7.

Trying to add a create a replica set but when ever I try to add a second server I get this error:

devshardcfgrs:PRIMARY> rs.add("s2-b6:26052")
{
"ok" : 0,
"errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only t he following 1 voting nodes responded: s1-b5:26051; the following nodes did not respond affirmatively: s 2-b6:26052 failed with No route to host",
"code" : 74,
"codeName" : "NodeNotFound"

What am I doing wrong?

This is my /etc/hosts file:

127.0.0.1 localhost

::1 localhost

172.24.1.42 s1-b5

172.24.1.43 s2-b6

All help is appreciated 🙂

Best Answer

Firewall! Go to the command line of s1-b5 and give command mongo --host 's2-b6:26052' you should have a successful login to "second" node. I guess that these two nodes are actually one machine?!? And when you use "external IP address", traffic goes thru the firewall. So, iptables-save command should show that this port 26052 is open for traffic.