I have setup mongodb to listen on 27017 on 127.0.0.1 only. I need to keep it this way to have security on my database. Though i need to be able to connect to mongodb remotely using the Robo 3T. Is there any way to connect using the ssh connection to tunnel the connection to the localhost listening mongodb using my ssh credentials?
P.S. I kinda beginner to the mongoDB. Thanks in advance...
I've done few configurations on my Ubuntu 18 Vagrant box in order to successfully connect MongoDB remotely using Robo 3T GUI. I've explained in the following steps.
On Ubuntu server, to open mongo shell run:
$ mongo
Inside mongo shell, type following command to create new a admin user.
> use admin;
> db.createUser({user:"admin", pwd:"password", roles:[{ role: "root", db: "admin" }]});
By default mongodb is configured to allow connections only from localhost(IP 127.0.0.1). We need to allow remote connections from any ip address. The following change should only be done in your development server. Open up etc/mongod.conf file and do the following change.
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 #default value is 127.0.0.1
Also in the same mongod.conf file uncomment security option and add authorization option as shown below.
security:
authorization: enabled
Save and exit the mongod.conf file and restart mongodb server.
$ sudo service mongod restart
Download and install Robo 3T GUI tool.
On Robo 3T GUI, in the connection settings, you need to do few changes as shown on
below screen shots.
Enter mongodb admin database username and password which you have created earlier.
Here, I have entered my Ubuntu 18 Vagrant box ssh credentials.
Save the changes and press connect icon to see if the connection is working fine.
Yes, you can use SSH tunnel.
Go to: MongoDB Connections (Ctrl + N) > Create / Edit > SSH tab
Just achieved that
No need to change nothing in your mongodb settings
In robomongo use localhost:27017 as you db address
In SSH tab add your login details.
I want to connect to a remote database using Robomongo. I can connect to to database but an error says that:
Failed to load list of databases
What should I do?
It took me 7 days to figure it out. When I have upgraded to Robo 3T version 1.3. it started working just fine. My previous version was 1.2.
Good to know if you are having this issue.
In my experience, it is related to failed database user/password authentication. So probably your IP connection to server is successful but you failed to connect to db. I suggest to double check your database username/password and try again.
And better to show what is inside "Show error details".
Go to Connection Settings -> Authentication
- Provide Database name, username, password
- Now test the connection
I ran into the same issue, then I provided the above info which solved my issue
Refer: (Vaibhav's post) Point 3.Populate DB name and username and password How to connect Robomongo to MongoDB
I have faced the same problem after updating the MongoDB version from 3.6 to 4.2 and previously I was using the Robo 3T version 1.2. So I just updated the Robo 3T version from 1.2 to 1.3 and it's started working again.
This is because whatever user you are connecting as does not have the privileges to list the databases.
https://docs.mongodb.com/manual/reference/built-in-roles/
Note that a user/role can connect and interact with a specific database/collection, but in order for Robomongo to list out the databases/collections, you need to let it connect to your database using a user that has listDatabases privileges.
check that your user has read/write & list all Databases privileges.
I had the same error ("failed to load a list of databases"). Due to some reason all my databases and collections got removed. Apparently, Robomongo couldn't handle the situation when there are no databases/collections available on the server.
To solve the issue, I connected to Mongo Shell, created a database, and created a collection there:
mongo (start mongo shell)
use local (create database named local)
db.createCollection("somename")
After that, I could connect to the Mongo server
Update: I've faced this issue again, and this time it has been caused by the fact that it was a new Mongo installation on a virtual machine, and connections from other hosts weren't allowed, so I had to modify bindIP from 127.0.0.1 to 0.0.0.0 in /etc/mongod.conf
net:
bindIp: 0.0.0.0
port: 27017
and restart mongo sudo service mongod restart
Got the same issue when using mongodb version v4.2.0, but the auth settings don't help. Keep getting the following logs when connecting from Robo 3T(i.e.mongoRobo).
2019-09-30T16:41:52.286-0400 I NETWORK [listener] connection accepted from 127.0.0.1:53862 #1 (1 connection now open)
2019-09-30T16:41:52.286-0400 I NETWORK [conn1] received client metadata from 127.0.0.1:53862 conn1: { application: { name: "robo3t" }, driver: { name: "MongoDB Internal Client", version: "3.4.3-10-g865d2fb" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "17.7.0" } }
2019-09-30T16:41:52.292-0400 E - [conn1] Assertion: Location34348: cannot translate opcode 2010 src/mongo/rpc/message.h 120
2019-09-30T16:41:52.292-0400 I NETWORK [conn1] DBException handling request, closing client connection: Location34348: cannot translate opcode 2010
2019-09-30T16:41:52.292-0400 I NETWORK [conn1] end connection 127.0.0.1:53862 (0 connections now open)
Finally resolved it by upgrading Robo 3T to v1.3(mac)
I just found out that I have to upgrade to the latest version that supports latest version of MongoDB. It worked without any authentication.
I had the same issue when I upgraded mongodb from 3.2 to 5.0 and tried to connect on Robo 3T 1.2.
Then I installed Mongo Compass, issue resolved. Issue would be resolved installing Robo 3T 1.3 too.
If you are using mongod --auth --dbpath /data/db1 command to start MongoDB, remove --auth and start it.
mongod --dbpath /data/db1
Now Robomongo will be able to connect without authentication. But starting without authentication is not safe. So take another terminal and create a user for your db using mongo command as described in this article.
use myDB
db.createUser(
{
user: "myUserAdmin",
pwd: "abc123",
roles: [ { role: "dbAdminAnyDatabase", db: "admin" } ]
}
)
Now restart your MongoDB with --auth. Connect with Robomongo after configuring above authentication details in its connection settings.
mongod --auth --dbpath /data/db1
I had the same problem (using Robomongo), then, I created an user with his password to connect to the database, and now It is working ok
In my case i changed the configurations of my connection:
You go to: Manager connection >> Edit >> authentication >> rename to database to: admin
when I loaded the my connection all databases appeared.
Start mongod process. Start mongo process.
On the mongo shell you have opened type first rs.status() then rs.initiate() then rs.status().
My version is 1.4.3 Robo3T.
What worked for me is;
Go to MongoDB Connections and edit related connection
Go to Connection Settings
Under Authentication tab check the "Manually Specify visible
databases" and fill in the dbName you need to access.
It should fix.
I faced a similar issue but it was due to my own mistake. I added replication configuration int the /etc/mongod.conf file (i.e replSet name) and restarted the mongod.service without doing an rs.initiate()
After doing an rs.initiate() and doing a restart of mongod.service, my issue was resolved.
This issue only exists with ROBO3T 1.2 update to a higher version and it will go. The reason behind it is version 1.2 takes authentication but when we don't provide credentials in case of local it does not run listdatabase on startup
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
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
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/).