Not able to connect MongoDB Compass - mongodb

I am not able to connect my server in MongoDB Compass. I am trying to connect by identity file. I am providing hostname username and file.
I got:
'Error creating SSH Tunnel: Timed out while waiting for forwardOut'
What does it mean?

Hi, krl! I was getting the exact same error from MongoDB Compass Community 1.11.1 while trying to connect through an SSH tunnel, with a ppk file protected by a passphrase.
Are you putting your remote server IP or domain name in the first field (hostname)? That was my mistake.
What solved it for me was setting the Hostname field (the first one on top) to localhost instead of remote server IP or domain name. Put your domain/IP only on the field SSH Hostname.
I hope it helps.

Related

MongoServerSelectionError: connection <monitor> to <MyIP> closed

I have started learning MongoDB, I am just trying to connect to the database using MongoDB Shell.
I am using the below command.
mongosh "mongodb+srv://cluster0.12345.mongodb.net/myFirstDatabase" --username viveknuna
I have added my current IP Address to IP Access List. But getting this error.
MongoServerSelectionError: connection to closed
I have referred to this question and added 0.0.0.0/0 (Allow access from AnyWhere) in the IP Access List. and it works as expected. But this is a security risk, Is there any way without allowing all IPs.
FYI: I am inside Virtual Machine and running this command also from VM.
in my case when i got these error MongoServerSelectionError: connection <monitor> to 16.163.195.9:27017 closed
I actualy put the wrong ip address i put my private ip; thats why.
i fixed it by changing the ip address in the IP List from WAN IP to my Public IP address thats how i fixed it, just search what is my ip, in you favorite seach Engine and it will show you your public ip in the result.
For me this error was occurring because my connection string was wrong.To be very specific - I copied the sample connection string from a course I was learning and just replaced the username and password with my credentials. So, the credentials were right but not the rest of the connection string.
Just for the sake of understanding. Please see below :
mongodb+srv://myusername:mypassword#courseproject.h1mpg.mongodb.net/?retryWrites=true&w=majority"
myusername and mypassword are correct i.e belongs to my cluster in MongoDB atlas account, but the rest of the string is wrong as I copied it from somewhere instead of copying it from my own MongoDB atlas account.
So please make sure to double check if your entire connection string is correct.
This happens when your ip address on the remote mongoDb is not the same as the public ip address of your computer. Simply go to network access on atlas and add your public ip address. Also, if your ip address is the same as that on the remote mongoDb then probably the connection closed after some period(default is 6hours).Thus when adding a your ip, unsure you toggle and set the duration for the connection (max is a week)

How to connect mongodb(installed on ec2) to Robomongo?

I have mongodb installed on aws ec2 up and running. Now i want to connect that mongodb to my Robo3T client. So in connection tab i put my public ipv4 ip in address field, put 27017 in port(connection tab).
Then in SSH tab of Robo3t i again put my public ipv4 ip in SSH address field and put 22 in port field. in SSH User Name field i put default ubuntuand select private key method from dropdown SSH Auth Method field. Then i browse my .pem file. But it is not connecting and giving me this error
What am i doing wrong?
I also have done port configuration on aws. Please see below :
You need to set Address: localhost

Connect to EC2 via MongoDB Compass Community

I have an EC2 instance (Ubuntu 14). I've defined port 27017 in its security group to be accessed from anywhere.
I'm trying to connect from my PC (Windows 10) to the EC2 instance, but getting the following error:
MongoDB not running on the provided host and port
which is not true since I've made sure that MongoDB is running.
These were the settings I specified:
I've also tried to use SSH (which is also defined in the sercurity group and works well through terminal), but got the following error:
Error creating SSH Tunnel: (SSH) Channel open failure: Connection
refused
These were the settings I specified:
Alon,
Checkpoints
See if there is a need to change the bind_ip variable at the /etc/mongodb.conf file.
By default, it is locked to localhost.
Try setting the value to 0.0.0.0 or assign the IP that will be able to connect the DB to it.
Port is allowed in security group attached to EC2 (You mentioned its done)
Not using private IP to connect (I guess, you are using the right one as you connected through terminal)
Rare case, OS firewall
I guess point 1 should do the trick. Rest points for future reference
[Update 1]
Doc link for bindIp
https://docs.mongodb.com/manual/reference/configuration-options/#net-options
I am putting this as an answer although it is meant as a comment to the answer by raevilman above but I do not have the necessary reputation to post comments yet.
If you set the bind_ip variable to 0.0.0.0 as mentioned, MongoDB accepts connections from all IP addresses. This might be a security risk if you do not use access control.
On the other hand, if I am not wrong, the idea of a SSH tunnel is for that, in this case MongoDB, the entering connection comes from localhost so no change in the configuration should be necessary.
That said, I came here because I could not connect either. I got the error 'Error creating SSH Tunnel: Timed out while waiting for forwardOut'.
In my case the solution was to put 'localhost' in the hostname field at the top instead of the host IP.

Can't remotely connect to MongoDB through an SSH channel

I am having an issue connecting to a mongoDB through SSH. I commented out the bind_ip option (and then added the authorization option). But to no avail. I even allowed the port through my firewalls. I get this error
"Cannot establish SSH Tunnel (IP:22).
Error: Failed to create a SSH channel"
It is worth mentioning I am using Robo 3T, and the first step, connecting to the server passes.
You can try this:
Select whether Compass should connect to a MongoDB cluster via an SSH tunnel, which automatically starts when you connect to MongoDB, and stops when you disconnect. If selected, choose either a password or an identity file to provide authentication.
Link: https://docs.mongodb.com/compass/master/connect/

How can i connect with mongodb in SlamData for my EC2 server

I can successfully connected with mongodb on SlamData but for my localhost. Now I have a mongodb database on my EC2 server that database i want to connect in Ec2 then How can I ?
I know username and password. What should be a host and port?
If you are running Slamdata on your host and want to connect to MongoDB running on a remote EC2 host.
Then apart from the username and password, the host is the Public IP or host FQDN [ec2-xxxxxxx], port is 27017. For this check if your mongos is running and binding on 0.0.0.0. If it is binding to 127.0.0.1, you cannot connect remotely
Also check you AWS security group for EC2 and see that the port 27017 is open for your IP or in general to all [0.0.0.0] (this is NOT recommended!!!)
You can also review the FAQ on docs.slamdata.com located here.
Provides step-by-step troubleshooting for connecting to cloud-hosted MongoDB servers.
Additionally, the Path value refers to path inside of SlamData rather than the operating system path. For instance entering a value of aws1 results in a query path similar to the following, assuming you have a databased named demo and a collection named coll1:
SELECT * FROM `/aws1/demo/coll1`