Can't access MongoDB 3.2.4 on CentOS 7 via 3T MongoChef - mongodb

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:
But if I set it :
then I get:
I have no idea how to fix this. Please help.

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

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.
Save and cycle the Mongod
In RHEL;
systemctl restart mongod

Related

Unable to connect to MongDB through IP address

I have installed MongoDb 4.0 on Windows 10. MongoDB currently runs on 'localhost'. I am able to connect to MongoDB by using 'mongodb://localhost:27017' in my nodeJS. However, I have a need to access this MondoDB instance through IP address. So, if I access MondoDB using mongodb://193.168.16.1:27017, then I am not able to connect to it. I tried to connect through MongoDB atlas, but I am having the same problem.
I have gone through the following threads on stackoverflow before posting it here.
Bind MongoDB to IP address when running as Service
Windows mongodb server bind_ip configuration
I have already tried to change the bindIp in mongod.cfg with the following values, with no success. I restarted 'MongoDB server' service after making these changes.I have also enabled all connections on port 27017 in windows firewall
bindIpAll: true #no success
bindIp: 127.0.0.1,193.168.16.1 #no success
bindIp: 193.168.16.1 #no success
bindIp: 0.0.0.0 #no success
I think you need to start your mongodb server something like this,
mongod --bind_ip 0.0.0.0 -v
And now you will be able to connect to mongodb using ipAddress.
Firstly please kill MongoDB and run this:
mongod --bind_ip 0.0.0.0 -v
Then as you want to connect through IP so run this command:
mongo --host 193.168.16.1 --verbose
Hope this will solve your problem...
None of the above suggestions worked for me. One of the combinations that worked for me is as follows
bindIp: 0.0.0.0,192.168.16.1
I am not sure why other combinations are not working. It could possibly be due to some issue with the MogoDb service, because I had to restart the service twice to get it working.
For me, it was not reading the config file until I removed the service and created it again specifying the configuration file path.
mongod --remove
"C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe" --config "C:\Program Files\MongoDB\Server\4.0\bin\mongod.cfg" --service
I had to comment #mp: at the end of the configuration file before I could run the service.

Remote connection doesn't work for MongoDB 3.2.9 (even after commenting out bindIp)

I am unable to remotely connect to MongoDB 3.2.9 installed on a Windows 7 machine.
I have tried -
Setting bindIp to 0.0.0.0 in mongod.conf
Setting bindIp to specific IP addresses
Commenting out bindIp
(And of course, I have restarted MongoDB service after making any change to mongod.conf)
However, when I uninstalled MongoDB 3.2.9 and installed MongoDB 3.0.6 instead, I am able to connect to it remotely.
I would really appreciate any help or pointers regarding this.
try
mongo 0.0.0.0:27017/test -u username -p password
instead of
mongo username:password#0.0.0.0:27017/test

Access MongoDB from other server

I have a MongoDB database on my Linux server. I want to access it from another server. I tried to make a connection from my local computer with the Robomongo. The connection is succesfull, but the authentication fails.
How can I get the authentication credentials? Or should I change something in MongoDB before I can acces the database from another server / pc?
Someone else have set up this database, and there is no possibility to ask him this questions.
I have found the solution by my self:
The File etc/mongod.conf has a line 'bind_ip'. In this line, you originally have to add the IP address which you want to access your database. But, it don't work! You should better comment this line.
But, you don't have any authentication now, so you have to add authentication. Here you have an tutorial about this: http://ghosttx.com/2012/03/how-to-connect-to-a-remote-mongodb-server-with-mongohub-for-mac/
When you have done that, you have to enable authentication. You can do this by editing etc/mongod.conf again, and uncomment the line 'Auth = true'.
Now you can connect with you Mongo Database ;)
Ive sorted it by adding ssh option to RoboMongo following this link:
http://www.mongovue.com/2011/08/04/mongovue-connection-to-remote-server-over-ssh/
Im on OSX and connecting to Ubuntu 14 / Mongo 2.6.7 on VPS and when Ive added my ssh details to the Robomongo all seem to work ok (Ive also changed the mongo config to remove the ip_bing and enabled port 27017)
If you do not like to bother with authentication and stuff just make an SSH Tunnel:
ssh -fN -l username -i .ssh/id_rsa -L 9999:localhost:27017 remote.com
Just connect to mongodb on localhost:9999 and it will establish a connection to your mongodb on port 27017 on your server at remote.com.
Run your mongodb with following command to access mongodb from other servers
mongod --port 10945 --bind_ip 0.0.0.0
I was not able to use Robomongo with MongoDB 3.0 too (connecting from a Windows machine to a Linux one, using SSH). The only tool that works for me is MongoChef (http://3t.io/mongochef/).

Can't connect my mongoDB database from my local machine

UPDATED:
I just start to deal with a new VPS and i am trying to connect its port 27017 (mongodb database) from localhost (using robomongo).
It's working on my localhost machine and with another remote server, but i can't connect mongodb on this VPS, what could cause this issue ?
I start it this way:
mongod --setParameter enableLocalhostAuthBypass=0 --config /etc/mongodb.conf --fork
with the auth = true uncommented in the /etc/mongodb.conf file (but it looks like the issue is not that i can't auth but mongodb is not responding at all).
When i start mongo admin -u root -p root by being connected with SSH, it works great (i can connect my database) and i can see that mongodb is well listenning on the port 27017.
But when i try to access it from my local machine, it can't establish the connection, and if i try to connect it with my browser, i am supposed to get a mongodb error message: You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number but i don't, i just have a failure page with Chrome (and the port 28017 is not responding either).
How to solve this ? My VPS is brand new and i could need to install more packages but i really don't see what could be need for this, it also looks like a firewall issue, like something prevent mongodb and response before the request could reach it, i have juste installed apache2 and nginx and they are not running so i really don't see...
Ok, I have found the issue!
There is a line bind_ip 127.0.0.1 in the /etc/mongod.conf file.
It provides access only to the specified IP address to mongodb.
You should create an array of IPs and edit the config file as:
bind_ip [127.0.0.1, x.x.x.x, ...]
Where x.x.x.x is your IP.
i resolved this issue with file(/etc/mongod.conf)
commenting out as follows:
#bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.

mongodb + remote access

I've installed mongodb on Linux(CenOS) server as it's written in docs. But still remote access is impossible (although conecting from mongo shell locally is ok). Can someone provide docs on proper configuring of mongodb?
Thank you in advance!
Source: MongoDb setup config to connect by remote hosts
On ubuntu:
root#debian:$ sudo nano /etc/mongodb.conf
Make sure you have the following lines
bind_ip = 0.0.0.0
port = 27017
root#debian:$ /etc/init.d/mongodb restart
Either running behind a firewall or mongod is bound to localhost only (use --bind-ip option to configure the IP address if necessary).