How do I set up MongoDB on the server to allow other computers to connect remotely?

  mongodb, question

For example, I installed MongoDB and started the service on this machine without any other settings. At this time, another machine can directly use ip such as 192.168.1.33:27017 for my machine.

But now I connect to a server through xshell, assuming ip is 192.168.1.4, login user name root, password 123456, MongoDB also starts the service, port is 27017, but other computers are not successfully connected through connection 192.168.1.4:27017, how do I need to set up the server? How to bring the user password at this time. The connection error prompt is a positive rejection by the target computer.

If you use MongoVUE to connect, you will not be able to do so either. You will be prompted to enter your user name and password. What I have filled in is the user name and password of the xshell connection server. MongoDB should have no user and password.

sudo netstat -nputl
 tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      1109/mongod

Look at MongoDB’s service listening address, so if you use 192.168.1.4, it is not linked and will be rejected. This one yuan should be
Mongod file adds the following line, which already exists. Please modify it

bind_ip = 0.0.0.0

In addition, if it is redhat,centos series, open the firewall port.

iptables -A INPUT -p tcp -m tcp --dport 27017 -j ACCEPT

Temporarily close selinux

setenforce 0