4

I have the following config file:

net:
  bindIp: 127.0.0.1
  port: 27017

storage:
  dbPath: c:\mongoDATA\db
  journal:
    enabled: true

##systemLog:
 ## destination: file
 ## path: C:\mongoDATA\log\mongodb.log   
 ## logAppend: true

this works, but when I try to add multiple ports like:

bindIp: 127.0.0.1, 192.168.10.115
or
bindIp: "127.0.0.1, 192.168.10.115"
or
bindIp: [127.0.0.1, 192.168.10.115]

with or without the space after the comma it doesn't. Could someone provide the write syntax? Thanks (using 3.6 community)

DCR
  • 171
  • 1
  • 2
  • 8

3 Answers3

1

without a space after the comma, AND the ip address has to present

DCR
  • 171
  • 1
  • 2
  • 8
0

@DCR, Wrap the comma-separated-Ips with brackets.

For example suppose that we have multiple ips like (192.168.10.115,96.88.169.145) and loop back ip(127.0.0.1) then the binding syntax will be as mention below

bindIp = [127.0.0.1, 192.168.10.115, 96.88.169.145]

For further your ref Fix bindIp multiple address notation in Configuration Options, Here,Here and How to set mongod.conf bind_ip with multiple ip address

Md Haidar Ali Khan
  • 6,523
  • 9
  • 40
  • 62
0

For 4.4.6, so - lets assume for series 4.x (perhaps for some of series 3.x)

The correct syntax is:

  • bindIp: 127.0.0.1,<private_host_ip>,<public_host_ip>

For each new IP just use , and without any spaces

For LAN access must be used the private_host_ip, you can use ipconfig or ip a for Windows and Linux respectively to know the ip value. Of course for public WAN access must be used <public_host_ip>, it about your ISP

Warning both ips - private_host_ip and <public_host_ip> - are the locations where your MongoDB server is running, not the remote clients. Therefore exists the wrong assumption to add each new ip where each one represents the remote client IP address (other different than the server IP address - LAN and/or WAN), it is not correct.

Note To avoid problems is better for both use static ips, the private through your router and the second through your ISP.

Manuel Jordan
  • 229
  • 2
  • 5