1

The Problem

I am trying but failing, in MongoDB 7.0, on Ubuntu, to bind multiple IP addresses to net.bindIp in mongod.conf

What I have tried

I have tried 127.0.0.1,x.x.x.x, 127.0.0.1;x.x.x.x, [127.0.0.1,x.x.x.x], [127.0.0.1;x.x.x.x] and mongod fails to start on each and everyone.

when the syntax is

[127.0.0.1,x.x.x.x] I get this error

Aug 22 11:52:36 ip-172-26-1-93 mongod[41708]: Scalar option 'net.bindIp' must be a single value

and when I use any other syntax, I get this error

Aug 22 11:54:38 ip-172-26-1-93 mongod[41723]: {"t":{"$date":"2023-08-22T11:54:38.935Z"},"s":"I",  "c":"CONTROL",  "id":7484500, "ctx":"main","msg":"Environment variable MONGODB_CONFIG_OVERRIDE_NOFORK == 1, overriding \"processManagement.fork\" to false"}

Where I have looked

After searching this extensively, I found this answer here and the answers to this question here and after tryin their solutions I still get the same errors.

I have looked at the documentation for the latest version and I can't see where I am going wrong.

Additional

I can successfully bind 0.0.0.0, however this then defeats the object of using net.bindIp

Edit

  1. I have tried reinstalling MongoDB 3 times now, and still the same issue
Yenmangu
  • 11
  • 2

2 Answers2

0

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.

https://www.mongodb.com/community/forums/t/socketexception-cannot-assign-requested-address/10964

In most cases, you can use localhost, 127.0.0.1, and the server name. Otherwise, just 0.0.0.0 for all the IP or hostnames that are assigned to the host server if the server has multi IP addresses or multi hostnames.

jelongpark
  • 51
  • 4
-1

Actually there is no reason to assign multiple IP-Addresses. This makes only sense on a computer with multiple network interfaces. However, since MongoDB does not support multiple network interfaces, it would be pointless anyway.

Either use net.bindIpAll: true if you like to permit connections from remote machines or use net.bindIp: localhost if you need to permit connections only from the local machine.

Anything else does not make much sense.

Wernfried Domscheit
  • 3,038
  • 1
  • 16
  • 16