SocketException: Cannot assign requested address

Hi there,

I spent over 24 hours reading all the docs and all the forums but I cant get my Replica Set deployed.

I setup 3 ubuntu instances in AWS, all on the same subnet with the same security group.
I installed MongoDB on all three in the same way
I tested that all three can talk to each other over local ips
I added all 3 hostnames on each /etc/hosts file
I added the same mongodb.conf settings to all three like so

replication:
   replSetName: "rs0"

net:
  port: 27017
  bindIp: mongodb-01,mongodb-02,mongodb-03

But it’s failing to start after I edit the conf file.

{"t":{"$date":"2020-10-28T09:12:43.784+00:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/etc/mongod.conf","net":{"bindIp":"mongodb-01,mongodb-02,mongodb-03","port":27017},"processManagement":{"timeZoneInfo":"/usr/share/zoneinfo"},"replication":{"replSetName":"rs0"},"storage":{"dbPath":"/var/lib/mongodb","journal":{"enabled":true}},"systemLog":{"destination":"file","logAppend":true,"path":"/var/log/mongodb/mongod.log"}}}}
{"t":{"$date":"2020-10-28T09:12:43.786+00:00"},"s":"E",  "c":"STORAGE",  "id":20568,   "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Cannot assign requested address"}}}

PLEASE HELP ME :pray:

Peter

Hi @Peter_Smith

The bindIP should be the ip address or hostname of the host.

The mongod cannot bind an ip addrress of another host.

This should be the relevant section on each host.

net:
  port: 27017
  bindIp: mongodb-01
net:
  port: 27017
  bindIp: mongodb-02
net:
  port: 27017
  bindIp: mongodb-03
2 Likes

Thanks so much Chris, ill give that whirl :+1:

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