adding localhost to mongo atlas whitelist - mongodb

I've been using the option allow everyone connection to my atlas cluster by selecting the "Allow Access from Anywhere" button in the group IP whitelist.
Is there a way to just add my localhost ip address instead. I tried doing it but I got the following error :
/me/node_modules/mongodb/lib/replset.js:364
process.nextTick(function() { throw err; })
^
MongoError: connection 4 to cluster0blbla.net:27017 closed
Anyone know of a way to add localhost connection without opening security up to everyone ?

Yes you can always add your local IP Address by going to:
Security - > IP Whitelist and then add a new IP. There you can click "ADD CURRENT IP ADDRESS" along with any comment:

Related

How to get the IP address of Heroku so that my Heroku hosted backend server can connect to MongoDB?

I'm trying to host my backend on Heroku, but after I tried deploying I was getting an "application error" . I checked the "heroku logs" and I think the problem is my MongoDB database only accepts connection to my specific IP address.
2023-02-07T09:34:05.807213+00:00 app[web.1]: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
How do I get the IP address of Heroku so that I can add it to this whitelist?
https://i.imgur.com/K9k0TFk.png
This is the entire Heroku log just in case maybe I'm wrong about the reason it's crashing?
https://pastebin.com/btc79fQq
EDIT:
Also is there a way to connect to the mongo atlas database with username + password instead of IP address maybe?
It seems like it's very dynamic so you need an addon like Fixie socks which sets a static IP of your Heroku app for this exact purpose.

Can't connect to amazon rds

I just setup aws rds and I'm trying to connect pgadmin to it. I put in the Endpoint and the port shown in the rds dashboard, and the username and password I set. When I try connecting, I get an error message saying: Unable to connect to server "host name" port "port" failed: timeout expired.
I also tried connecting prisma to it by running npx prisma migrate dev --name init and I also get an error saying P1001: Can't reach database server at "host name".
I made sure to set Publicly accessible to Yes, but it's still not working. What am I doing wrong and how can I fix it?
(For the settings, I used the default free tier settings.)
In the question thread, the security group is defined to accept All Traffic from all IPv6 addresses ::/0. Permission for IPv4 address should be added as well. You may want to address All Traffic for IPv4 address 0.0.0.0/0.

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

Not able to connect MongoDB Compass

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.