Failing to connect to remote mongodb server

前端 未结 1 1515
鱼传尺愫
鱼传尺愫 2021-02-05 09:16

I am trying to create a remote mongodb server to work with on my java project.

I am using vagrant + ansible to create the environment, but fr soem reson i cannot get a c

1条回答
  •  深忆病人
    2021-02-05 09:33

    Firstly, To ensure its not a firewall issue, stop IPTABLES on both servers (don't forget to re-enable afterwards).

    On the machine that you are trying to connect to, ssh directly to it and ensure MongoDB is running, Connect locally and check that you can access a DB.

    MongoDb isn't configured to accept connections from remote hosts by default, could you ensure you have these lines in your /etc/mongodb.conf file:

    bind_ip = 0.0.0.0
    port = 27017
    

    Make sure you restart MongoDB after making any changes. Try this and comment if your still having issues and I'll update the answer with more suggestions.

    EDIT: As of version 2.6 the config file format has changed to YAML, details here, the file should be located at /etc/mongod.conf.

    net:
       bindIp: 0.0.0.0
       port: 27017
    

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