Use Robo 3T to connect to remote MongoDB

13,283

Solution 1

The correct setting is

1) under SSH, check User SSH tunnel, use port 22

2) and under Connection, write 127.0.0.1:27017

Solution 2

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.

  1. On Ubuntu server, to open mongo shell run:
    $ mongo
    
  2. 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" }]});
    
  3. 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
    
  4. Save and exit the mongod.conf file and restart mongodb server.

    $ sudo servcie mongod restart
    
  5. Download and install Robo 3T GUI tool.

  6. On Robo 3T GUI, in the connection settings, you need to do few changes as shown on below screen shots.

enter image description here

Enter mongodb admin database username and password which you have created earlier.

enter image description here

Here, I have entered my Ubuntu 18 Vagrant box ssh credentials.

enter image description here

Save the changes and press connect icon to see if the connection is working fine.

Solution 3

Connect to remote MongoDB using Roto3t

Firstly, we should check the standard URI connection scheme for mongodb

mongodb://[username:password@]host1[:port1][,...hostN[:portN]]][/[database][?options]]

We make a SSH Connection to the remote MongoDB on Cloudfoundry

in my case cf ssh -L port_forwarding:HOST_NAME:Port NAME_OF_APP

(1) In the Connection tab in Robo3T we choose

Type: direct connection
Name: choose_any_connection_name
Address: localhost and port is 'port_forwarding' we choose in the SSH connection we made.

(2) in the Authentication tab, we should add database, username, password, and Auth Machanism: SCRAM-SHA-1

(3) in the SSH Tab we will uncheck use SSH tunnel as we made it manually. Now, if you click test the connection should be successfully done.

Note: If we use Studio 3T it will parse the URI and fill all these fields for us.

Share:
13,283
SoftTimur
Author by

SoftTimur

Updated on June 20, 2022

Comments

  • SoftTimur
    SoftTimur almost 2 years

    I'm trying to use Robomongo (or Robo 3T) under Mac to control my mongodb in the remote Ubuntu & Nginx server.

    Normally, I need to ssh xxx.xx.xx.xx in a terminal with a username and a password to connect to the server. in /etc/nginx/sites-enabled/myweb.io, there is listen 443 ssl.

    In Robo 3T, I tried to set up the connection with Use SSH tunnel. I tried the port number 443 or 80. But it gave me an error: Error: Resource temporarily unavailable. Error when starting up SSH session: -13. (Error #35)

    Does anyone know how to fix this?

    enter image description here

  • Dennis
    Dennis over 2 years
    Thank you, this worked for my purposes. Just to clarify for other users--the config file is in /etc/mongod.conf.