MongoDB bind_ip won't work unless set to 0.0.0.0

后端 未结 12 779
遇见更好的自我
遇见更好的自我 2020-12-04 23:43

I really tried, even reinstall the MongoDB.

And it\'s the same to MongoDB bind_ip error: bind() failed errno:99 Cannot assign requested address for socket

It

相关标签:
12条回答
  • 2020-12-05 00:21

    This is a notation that only works on Ubuntu: (watch out on spaces, symbols)

    bind_ip=[127.0.0.1,22.33.44.99,88.77.55.66] 
    

    22.33.44.99 - my static ip of server, 88.77.55.66 - my static ip of laptop. That gave me an opportunity to access to mongodb out from internet. Don't forget to add a rule - open port 27017 to ufw.

    0 讨论(0)
  • 2020-12-05 00:22

    Using MongoDB 4.0.5: For me the following worked:

    bindIp=[127.0.0.1,11.22.33.44]
    

    And then I switched on Auth:

    security:
       authorization: "enabled"
    

    Restarting mongod (on Ubuntu 18.04) gave an error:

    Scalar option 'net.bindIp' must be a single value

    Therefore I had to do the bindIp: 0.0.0.0. Maybe somebody has a clue how to combine bindIp and Security

    0 讨论(0)
  • 2020-12-05 00:24

    I had the same issue just because of the silly mistake.

    There was commented line and space problem.

    What I did wrong

    # network interfaces
    net:
      port: 27017
     #bindIp: 127.0.0.1
    bindIp: privateIp
    

    instead of

    net:
      port: 27017
      bindIp: 10.1.2.4
    

    for bind to multiples ips

    bindIp: [127.0.0.1,10.128.0.2]
    

    hopefully this answer helpful for someone.

    0 讨论(0)
  • 2020-12-05 00:24

    In my case, none of the options above worked. The specification that finally worked for me was:

    bind_ip= [<IP_one> <IP_two>]
    
    

    An example could be:

    bind_ip= [127.0.0.1 10.0.0.4]
    
    

    (Notice that there is no comma between the two directions)

    I have MongoDB 2.6.10 on Ubuntu 16.4.5 (LTS)

    0 讨论(0)
  • 2020-12-05 00:27

    Edit: I do not know wether I was simply wrong with my answer or if the behavior of bind_ip was changed, but it is possible to bind to multiple, distinct IPs

    bind_ip:127.0.0.1,10.0.0.1,8.8.8.8
    

    So, most likely, one of the IP addresses mongod was assigned to bind to did not exist on the machine in question.


    You can bind mongod only to one IP, with 0.0.0.0 being the alias for "listen on all available network interfaces".

    So either use

    bind_ip=127.0.0.1
    

    to listen to the loop back interface or

    bind_ip=<someIP>
    

    to listen to that IP only or

    bind_ip=0.0.0.0
    

    to listen to all available IPs on the system.

    If you need to listen to several specific IPs, it is very likely that your system design is somehow screwed.

    0 讨论(0)
  • 2020-12-05 00:28

    Hey I am using MongoDB shell version: 3.2.6 .

    bindIP = 127.0.0.1,192.168.0.50 
    bindIP = [127.0.0.1,192.168.0.50]
    bind_ip = 192.168.6.38 
    

    not working , i have edited mongod.conf using this command

    sudo -i gedit /etc/mongod.conf file 
    

    And Changed bind_ip = 0.0.0.0 to bind_ip = 192.168.6.38 it working fine ....

    0 讨论(0)
提交回复
热议问题