how to connect another machine mongodb database inside local network ?

后端 未结 3 1879
傲寒
傲寒 2021-01-05 11:00

I follow this mongoose document enter link description here

mongoose.connect(\'mongodb://localhost/waterDB\');

Using This, I can connect lo

3条回答
  •  被撕碎了的回忆
    2021-01-05 11:57

    It might be a problem with your MongoDB instance listening on localhost only. You can change the bind address in MongoDB's configuration file. The config file may be located in /etc/mongodb.conf or /etc/mongod.conf. There are also 2 config file formats:

    Old format (still supported):

    bind_ip = 0.0.0.0
    

    YAML (version 2.6+):

    net:
        bindIp: 0.0.0.0
    

    After changing the config file you have to restart the MongoDB server.

提交回复
热议问题