I just created a cluster in Mongodb Atlas and I can't connect to it either by my application or by the compass, the compass says: the certificate is not yet valid.
mongodb+srv://tbussola:#tindintest.fptqm.mongodb.net/test
In the application of moongose it points out: ould does not connect to any server in your MongoDB Atlas cluster. A common reason is that you are trying to access the database from an IP that is not whitelisted. Make sure that your current IP address is on the Atlas cluster IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
mongodb+srv://tbussola:#tindintest.fptqm.mongodb.net/?retryWrites=true&w=majority
My ip is already listed in the whitelist and it is also enabled to allow any ip. What should I do now? I'm using Linux manjaro, I'm a beginner.
I was facing the same issue. After a lot of research I finally found this: certificate is not yet valid. The time on my pc was not my actual local time. After I sync my time from windows settings. Connection worked.
Related
This is my first attempt at deploying a Node.js application on a Google VM instance while connecting to MongoDB.
In MongoDB, I have whitelisted my IP address and the VM instance's IP address. When I start my server using Google Cloud Shell, I receive the following error:
op.cb(new error_1.MongoNetworkError(`connection ${this.id} to ${this.address} closed`));
^
MongoNetworkError: connection 1 to 34.71.95.215:27017 closed
I'm connecting on port 8080. The external IP is listed on my GCP instance page and when I ping it, it is up. IP: 34.68.254.120
When I whitelist 0.0.0.0/0 in Mongodb, the code runs successfully, and I can preview my app through GCP.
I created a new instance from scratch, and it also crashes with the same error.
ETA: In looking at the source code around the error message at:
...\node_modules\mongoose\node_modules\mongodb\lib\cmap\connection.js
it looks like a closed connection. The error message above spits out the IP address as the Iowa Google Data Center where my VM is housed.
I don't know what this means, but if you do, please let me know.
ETA2: I have 2 problems, and they may be connected. The first is that my VM server cannot connect to MongoDB. This should be simple -- whitelist the external IP address of my VM server. It does not work (I have to open MongoDB to 0.0.0.0/0 for it to connect).
The second is that I cannot connect to my server via the external IP address, regardless of whether MongoDB is connected or not. It "refuses to connect." I can do a web preview of my running server, though.
It seems the two may be connected somehow. I've rebooted my VM, but it did not fix anything. I whitelisted the error message IP address in MongoDB, but it did not help.
ETA3: Okay, it appears I have solved the whitelist to MongoDB issues. Through Cloud Shell, I asked my VM what the IP is. It is different than the one GCP tells me is the external IP. By adding this IP to the whitelist, I can connect between GCP VM and MongoDB. Whew. No idea why.
The VM's external IP address through my browser still gives me a cannot connect message, and when I use the new VM IP address I found through Cloud Shell, it gives me a "took too long to respond" message.
So I feel I have made progress. The remaining problem is accessing my server through Chrome.
Any suggestions on how I can investigate the issue further? I'm at a dead end. I believe the problem is likely simple given my inexperience.
Thanks!
Problem solved by a friend, for anyone in the future with this issue.
I had set up my GCP VM using Cloud Shell. I had housed my code by coping my repository through Cloud Shell. It turns out, this is more of a virtual interface with my VM, and the files are not physically on my VM. I needed to go through SSH, clone my repository there, and run my server through SSH. Cloud Shell was causing the problem.
I'm building a MERN stack application. While using a personal network the connection made to MongoDB atlas works fine, however when I work at office I'm unable to connect to MongoDB Atlas due to corporate proxy.
I keep getting the following error:
err 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/
PS: I've whitelisted my corporate IP address and have also tried network access from anywhere option but I keep getting the same error on corporate network
I had same problem and was not able to connect despite setting any Ip to network setting , I shared mobile internet then it did connect to db
We have mongodb running and everything is fine with it. I can connect to it from my kubernetes cluster and from my PC. I created new kubernetes cluster, assigned IP addresses from old cluster machines to new nodes and i'm not able to connect from those new nodes. Application and settings are the same.
When i try manually connect to mongodb then:
mongo mongodb://correct-username:correct-password#correct-IP
.......
Error: Authentication failed.
When i assign those IP's back to old cluster nodes then i'm able to connect again.
Only thing that has been changed is MAC address and OS. IP addresses are the same. Is there somekind of "connection cache". Differect MAC but same IP causing problems? I'm quite new with mongodb.
Authentication happens after a successful connection. Therefore, if you are receiving an authentication error, the connection succeeded.
Since authentication is orthogonal to IP addresses, you misconfigured something during your move.
Are you using Atlas instance or self-hosted MongoDB Server?
Maybe your current setup has IP Access List (whitelist of IP addresses) configured, and when you try to connect from somewhere which is not in that list, you will not be authenticated. You should check that, and if that is the problem, just add new IP addresses on the list.
Is this a mongodb replicaSet , standalone or sharded cluster, how rs.conf() looks like? If you configure the rs based on old ip-addresses this explain the issue... , you will need to rs.reconfig() and change to the new IPs...
I have set up a project in MongoDB atlas and created a user, followed the process as described in the documentation to white list IP, etc. However, I am not able to connect from my laptop.
Error is:
"HostNotFound: Could not find address for cluster0-6lzea.mongodb.net:27017: SocketException: No such host is known."
I have referred to similar questions, 2 of them were similar but their issue was because they dint white list the ip and another was blocked by universities' firewall. I do not have both the issues as I have whitelisted IP and I am not behind any firewall.
Recently i decided to move my database from inside my server machine to the MongoDB Atlas service.
Atlas provides a IP Whitelist feature which i use to remotely connect to the database cluster.
Should i plug my server application to Atlas using this feature?
What happens if my server IP changes? Is it secure?
For a general information on how to connect to an Atlas deployment, please see Connect to a Cluster
For connecting using a driver, please see Connect via Driver. There is an extensive list of examples using all of the officially-supported drivers.
As mentioned in the Prerequisites section, you need to use SSL/TLS and IP whitelist to connect to your Atlas instance. This whitelist would need to be updated should your application server's IP changes.
The whitelist provides an additional security layer in addition to your username/password, since this list will essentially reject any connection not originating from a known IP address. It is strongly recommended to utilize this whitelist, and arguably the effort required to maintain the whitelist is comparably small to the security advantages it provides.