6

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

SoftTimur
  • 5,630
  • 38
  • 140
  • 292
  • Try connecting without SSH Tunnel and SSH runs on port 22(in case you haven't changed it but you should change it). – Shubhamoy Nov 18 '17 at 05:29
  • If I connect without SSH Tunnel, which way should I use? – SoftTimur Nov 18 '17 at 05:31
  • Just uncheck the SSH Tunnel and try to connect. – Shubhamoy Nov 18 '17 at 05:33
  • I filled the port with 22, unchecked the SSH Tunnel, it gave me an error: `Cannot connect to the MongoDB at :0. Error: Network is unreachable.` – SoftTimur Nov 18 '17 at 05:34
  • This means the SSH Connection went through but wasn't able to connect to your MongoDB instance. Try checking on your server whether Mongo is running or not. – Shubhamoy Nov 18 '17 at 05:35
  • My server is always ON. By the way, what should I enter in `Address` under `Connection` tab of Robo 3T? – SoftTimur Nov 18 '17 at 05:37
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/159275/discussion-between-shubhamoy-chakrabarty-and-softtimur). – Shubhamoy Nov 18 '17 at 05:41

3 Answers3

13

The correct setting is

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

2) and under Connection, write 127.0.0.1:27017

SoftTimur
  • 5,630
  • 38
  • 140
  • 292
6

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.

Krishna
  • 1,107
  • 1
  • 12
  • 10
  • Thank you, this worked for my purposes. Just to clarify for other users--the config file is in `/etc/mongod.conf`. – Dennis Nov 22 '21 at 21:04
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.

Community
  • 1
  • 1