Keep getting ServerSelectionTimeoutError

Hello,

I keep getting this error with Python. This just started happening today, and I changed none of my code. I dont know whats happening.

> Ignoring exception in on_message
> Traceback (most recent call last):
>   File "C:\Users\trexx\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
>     await coro(*args, **kwargs)
>   File "c:\Users\trexx\Documents\PYTHON CODE LOL\SCP-16-Tsundere-Discord-Bot\SCP\levelsys.py", line 68, in on_message      
>     if DiscordGuild.find_one({"id":ctx.guild.id}, {"settings"})["settings"]["Profanity Filter"]["enabled"]==True:
>   File "C:\Users\trexx\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\collection.py", line 1319, in find_one
>     for result in cursor.limit(-1):
>   File "C:\Users\trexx\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\cursor.py", line 1207, in next
>     if len(self.__data) or self._refresh():
>   File "C:\Users\trexx\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\cursor.py", line 1100, in _refresh
>     self.__session = self.__collection.database.client._ensure_session()
>   File "C:\Users\trexx\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\mongo_client.py", line 1816, in _ensure_session
>     return self.__start_session(True, causal_consistency=False)
>   File "C:\Users\trexx\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\mongo_client.py", line 1766, in __start_session
>     server_session = self._get_server_session()
>   File "C:\Users\trexx\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\mongo_client.py", line 1802, in _get_server_session
>     return self._topology.get_server_session()
>   File "C:\Users\trexx\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\topology.py", line 501, in get_server_session
>     self._select_servers_loop(
>   File "C:\Users\trexx\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\topology.py", line 215, in _select_servers_loop
>     raise ServerSelectionTimeoutError(
> pymongo.errors.ServerSelectionTimeoutError: scp16cluseter-shard-00-01.foubt.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),scp16cluseter-shard-00-00.foubt.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),scp16cluseter-shard-00-02.foubt.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129), Timeout: 30s, Topology Description: <TopologyDescription id: 61550c4edb21d7a4c3463c25, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('scp16cluseter-shard-00-00.foubt.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('scp16cluseter-shard-00-00.foubt.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')>, <ServerDescription ('scp16cluseter-shard-00-01.foubt.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('scp16cluseter-shard-00-01.foubt.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')>, <ServerDescription ('scp16cluseter-shard-00-02.foubt.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('scp16cluseter-shard-00-02.foubt.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')>]>

I have tried changing to certificate connection instead of password connection, and I even reated a new database but that doesnt help either. Any help is appreciated

1 Like

Looks like this is the issue.

3 Likes

Hey,

I’m having the same issue here, using MongoDB Atlas- Seems like the Let’s Encrypt R3 signing CA expired today.

Is it possible to have Atlas TLS certificates re-provisioned?

Cheers,
George

Hi,

I too started getting this error from yesterday. When i try to add item/read items from the database using my pc, i get this error, But when i used another pc (server), it didn’t show me any error. It worked. Could anybody tell me how to rectify this error? i guess this problem is from MongoDB side. they may have updated their product. I hope technicians from MongoDB will rectify this error or let us know the solution for this problem. Thanks in advance

2 Likes

Hey,
Same error on a windows local dev environment with php. Wiresharked it and getting a Certificate Expired (45) error. That means “Received a certificate has expired or is not currently valid”.

Error started on 30.09. Before, the connection worked perfectly fine. No changes made in between.

Got the same error. Using Django on Windows. Error started on 2021-09-30T18:30:00Z. Haven’t made any changes since then. Would appreciate it if this get’s resolved soon

1 Like

I solved the problem on my windows machine. It had to do with the expiring DST Root CA X3 certificate from Let’s Encrypt. Connection didn’t work although the successor cert D-TRUST Root was installed. I had to Install the following certificates: ISRG Root X1, ISRG Root X2 ( Root Certificates), Let’s Encrypt R3 ( Intermediate Certificates). Found on Chain of Trust - Let’s Encrypt (letsencrypt.org).

Hope this helps
Cheers
Florian

5 Likes

My connection via PyMongo suddenly stopped working on Sept. 29, 2021. It seems problem is related to MongoDB Atlas certificates. I had to use this workaround:

May MongoDB Atlas admins announce such events explicitly and/or in advance :S

1 Like

I’ve tried everything, nothing helps.

1 Like

Same here. It was totally working fine and 2 days before ,it started showing the same erro.pymongo.errors.ServerSelectionTimeoutError: cluster0-shard-00-00.4…: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has
expired (_ssl.c:****). I tried to fins out the solution, but did not get any solution. Please provide solution for Windows system. Thanks

Hi Folks,

If you are suddenly encountering problems with TLS certificate validation when connecting to Atlas, this is likely due to older root certificates used by Let’s Encrypt expiring on Sept 30, 2021. MongoDB Atlas uses Let’s Encrypt to sign Atlas cluster TLS certificates.

This validation issue is on the client side of the connection, not the server. Your Atlas cluster certificates are still valid, but your local trust stores do not contain the new root certificate required for verification.

Common root certificates are generally included in O/S updates, but in some cases you may need to manually update trust stores used by your O/S or application environment.

For more information, please see: Which certificate authority signs MongoDB Atlas cluster TLS certificates?.

Regards,
Stennie

3 Likes

Thank’s a lot. This helped me also :slight_smile:

1 Like

This fixed the issue completely… Thank you!

1 Like
  1. Download https://letsencrypt.org/certs/lets-encrypt-r3.pem
  2. rename file .pem to .cer
  3. double click and install

and then try to run app your SSL issue will resolved. Cheers !!!

6 Likes

Thank you, this is by far the simplest solution. Took 30 seconds to complete!

2 Likes

It is working now. Thank you!

2 Likes

Bro Thank you so much,Ä°ts worked on my machine

1 Like