5

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.

2
  • share whay are you typing cause it's impossible to guess. Just hide user and passwords like so: XXX. YYY etc
    – user12582392
    Commented Nov 18, 2020 at 5:58
  • mongodb+srv://tbussola:<password>@tindintest.fptqm.mongodb.net/test
    – Bussola
    Commented Nov 18, 2020 at 11:38

2 Answers 2

11

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.

1
  • That was the solution, even 3 years later! Thanks.
    – Syno
    Commented Apr 2 at 13:46
3

Using Windows 10:

Step 1: Go to date time setting.

Step 2: Go to additional setting and click on Sync now.

That command will sync your system time with current time zone.

Now I am able to connect to MongoDB atlas.

2
  • 1
    Thank you for the straightforward solution to my issue that brought me to this question. I was trying to run the "realm-cli login" command and kept getting the error "login failed: Post ... x509: certificate has expired or is not yet valid: current time 2023-05-19T19:37:18+04:00 is before 2023-05-19T17:04:55Z". Soon after syncing system time. I was able to run "realm-cli login" successfully.
    – Jomeno
    Commented May 24, 2023 at 6:05
  • I faced the same issue on my WSL2 + Ubuntu 22.04 box. I was able to connect after issuing the command: sudo hwclock -s
    – Ankur
    Commented Mar 12 at 14:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.