Replica Set Network Issue - Windows OS

Hello Everyone, Hope all are doing well,

I will share an stranger issue regarding the Replica Set and hope to figure an solution for it.

I have a three nodes Replica Set:

1.) MongoNode1:27017 (Primary)        IP: 10.10.15.100
CFG File:   bindIp: 127.0.0.1,MongoNode1,10.10.15.100
2.) MongoNode2:27017 (Secondery)   IP: 10.10.15.101
CFG File:    bindIp: 127.0.0.1,MongoNode2,10.10.15.101
3.) MongoNode3:27017 (Arbitar)         IP: 10.10.15.102
CFG File:    bindIp: 127.0.0.1,MongoNode3,10.10.15.102

Everything was grate until we decided to buy a new server to work as primary instead of MongoNode1

But We forced to assign the MongoNode1 IP to The new PC, So the structure converted to the following:

1.) MongoNode4:27017 (Primary)        IP: 10.10.15.100
CFG File:   bindIp: 127.0.0.1,MongoNode4,10.10.15.100
2.) MongoNode1:27017 (Secondery)     IP: 10.10.15.103
CFG File:   bindIp: 127.0.0.1,MongoNode1,10.10.15.103
3.) MongoNode2:27017 (Secondery)   IP: 10.10.15.101
CFG File:    bindIp: 127.0.0.1,MongoNode2,10.10.15.101
4.) MongoNode3:27017 (Arbitar)         IP: 10.10.15.102
CFG File:    bindIp: 127.0.0.1,MongoNode3,10.10.15.102

In this case we just replaced the local IP address between 2 machines the new primary and the old primary and for sure we rebuild the replica set again but there are a stranger issue happened, the service is not running automatically in the new primary with the following error:

{"t":{"$date":"2023-06-22T07:46:08.622+03:00"},"s":"E",  "c":"CONTROL",  "id":20568,   "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"The requested address is not valid in its context."}}}

We tried everything even we tried to reinstall the new primary machine OS, also tried to reset the network many-times from the routers and PC.

Note: we can start the mongo manually from the services after we login to windows but it cannot start automatically never if we restarted the primary pc.

so what is the advice in this this case?

Thank you.

What ever IP address you using in the configuration for bindIp, it is not valid for this machine. You do not need to bindIp to both the host name, like MongoNode3 and its IP, like 10.10.15.102. From all nodes, share the output of the 4 commands:

ping -c 2 MongoNode1
ping -c 2 MongoNode2
ping -c 2 MongoNode3
ping -c 2 MongoNode4

I asked because you might have name resolver misconfiguration.

1 Like

Thank you for your reply, I already tried to use host names only without adding local ip(s) but I got an error during the replica set setup: node not found during rs.add()

Anyway here you go the output for every ping command:

Note: All of the following ping CMD are made in the MongoNode4 (New Master PC)

C:\Windows\system32>ping MongoNode1

Pinging MongoNode1 [10.10.15.103] with 32 bytes of data:
Reply from 10.10.15.103: bytes=32 time=1ms TTL=128
Reply from 10.10.15.103: bytes=32 time=1ms TTL=128
Reply from 10.10.15.103: bytes=32 time=1ms TTL=128
Reply from 10.10.15.103: bytes=32 time=1ms TTL=128

Ping statistics for 10.10.15.103:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 1ms, Average = 1ms
C:\Windows\system32>ping MongoNode2

Pinging MongoNode2 [10.10.15.101] with 32 bytes of data:
Reply from 10.10.15.101: bytes=32 time=1ms TTL=128
Reply from 10.10.15.101: bytes=32 time=1ms TTL=128
Reply from 10.10.15.101: bytes=32 time=1ms TTL=128
Reply from 10.10.15.101: bytes=32 time=2ms TTL=128

Ping statistics for 10.10.15.101:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 2ms, Average = 1ms
C:\Windows\system32>ping MongoNode3

Pinging MongoNode3 [10.10.15.102] with 32 bytes of data:
Reply from 10.10.15.102: bytes=32 time=1ms TTL=128
Reply from 10.10.15.102: bytes=32 time=1ms TTL=128
Reply from 10.10.15.102: bytes=32 time=1ms TTL=128
Reply from 10.10.15.102: bytes=32 time=2ms TTL=128

Ping statistics for 10.10.15.102:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 2ms, Average = 1ms
C:\Windows\system32>ping MongoNode4

Pinging MongoNode4 [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms

Ping statistics for ::1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Note: Kindly note that the mongo is running very good after I log into the windows and start it manually from the windows services, I am wondering why it is not working automatically after startup Why I am needing to login to windows?

Thank you,

You need to run the 4 ping commands from all the machines.

So
From MongoNode1, you run and share the result of the 4 pings.
From MongoNode2, you run and share the result of the 4 pings
From MongoNode3, you run and share the result of the 4 pings
From MongoNode4, you run and share the result of the 4 pings

But already we see that your networking has issues because MongoNode4 does not respond to ping:

You need to fix networking issues first.

It will be hard for use to tell if you do not share the error message you get and the server logs.

1 Like

Dear steevej ,
Thank you for trying to help me to solve this issue,
I guessed that there are something wrong with the new instance LAN Card, So I tried something new,
I forced the MongoDB Service to run as Automatic Delayed, in this case all the Windows OS services including The Lan/DHCP etc, Services will run at the first then the MongoDB Service will start later as (automatic delayed), and it is worked fine now and the issue has been resolved,

Note: I know it is takes around 2-3 mins more than usual to be ready but it is finally working as an automatic service.

Sorry for my bad english :slight_smile: Thanks.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.