2

I installed MongoDB 3.2.4 on CentOS 7. I keep the default configure except comment the bindIp: 127.0.0.1 to access the db via 3T MongoChef 3.4.1 from local machine.

I create two new users for db admin. One is root and one is userAdmin.

I tried to access the db via 3T MongoChef but failed. If I leave the Authentication none, I would get this:

enter image description here

But if I set it :

enter image description here

then I get:

enter image description here

I have no idea how to fix this. Please help.

Brick Yang
  • 5,388
  • 8
  • 34
  • 45
  • Hi! Have your try with other authentication method? If I don't remember bad, there is some incompatibilities between newest versions of mongod and some clients in regards to the authentication protocol. Give a try and let me know. Also, are you connecting with no problem using the "mongo shell"? In such case, could you let us now what version is it? – Héctor Valverde Mar 30 '16 at 13:34
  • Also, I see you are getting a timeout error ... this is probably due to network issues. What are you getting it you try to telnet to this "server port" ? – Héctor Valverde Mar 30 '16 at 13:35
  • @HéctorValverdePareja Hi. Another authentication choice is "X.509", I have no idea what this is. I can access the server and db via SSH, so I think the network should be fine. – Brick Yang Mar 30 '16 at 13:38
  • No, you should's assume the network is fine by ssh-ing to the server. SSH uses port 22 but you're trying to connect via 2017. Do: `telnet 27017` In order to verify you can connect to this port. Also, keep looking the mongod logs in case you have any other problem and, of course, make sure your mongod is listening to port 2017. You can do: `lsof -i :27017` to check this out. – Héctor Valverde Mar 30 '16 at 13:39
  • Are you using AWS or something like this? If so, you should review and set the security groups properly. – Héctor Valverde Mar 30 '16 at 13:42
  • @HéctorValverdePareja I tried as you said. I got `telnet: connect to address : Connection refused`, `telnet: Unable to connect to remote host`. And the mongodb is listening to 27017 correctly. – Brick Yang Mar 30 '16 at 13:43
  • @HéctorValverdePareja I have checked the security rules of the server, the port is allowed to access. In fact, the rule is `allow all`. – Brick Yang Mar 30 '16 at 13:45
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/107750/discussion-between-brick-yang-and-hector-valverde-pareja). – Brick Yang Mar 30 '16 at 13:48
  • Ok, so try to solve the following questions then: Is it your client machine allowing outbound connections through this port? Do you have a firewall between mongo and your client that may be blocking this port? Is mongod in a VPN or VPC you can't access to using this port? – Héctor Valverde Mar 30 '16 at 13:48

2 Answers2

1

It seems like commenting the bindIp out is not enough to change the allowed inbound connections for mongod. Try to change it to 0.0.0.0 instead.

Also, check this post out: mongodb.conf bind_ip = 127.0.0.1 does not work but 0.0.0.0 works

Regards

Community
  • 1
  • 1
Héctor Valverde
  • 1,089
  • 1
  • 14
  • 34
1

In the production environment, lock the IP down to white list server and don't open up using `

0.0.0.0

To Whitelist IPs, modify the mongod.conf

vim /etc/mongod.conf

Add the IPs in the following format

[x.x.x.x,x.x.x.x]

Ex. enter image description here

Save and cycle the Mongod In RHEL;

systemctl restart mongod

Gajen Sunthara
  • 4,470
  • 37
  • 23