Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Robo 3T to connect to remote MongoDB

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

like image 726
SoftTimur Avatar asked Nov 29 '22 08:11

SoftTimur


2 Answers

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.

like image 33
Krishna Avatar answered Dec 04 '22 05:12

Krishna


The correct setting is

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

2) and under Connection, write 127.0.0.1:27017

like image 183
SoftTimur Avatar answered Dec 04 '22 07:12

SoftTimur