Hello, I have been using pymongo with atlas for a while now, and suddenly around two hours ago, I must have done something wrong because the same code I’ve been using the entire time suddenly stopped working.
I have attempted to isolate the issue and made this reproducible example
from pymongo import MongoClient
client = MongoClient(
"mongodb+srv://culturebot:[pass]@cluster0.whzdc.mongodb.net/culturebot?retryWrites=true&w=majority"
)
print(client.list_database_names())
and this is the full traceback
Traceback (most recent call last):
File "C:\Users\D\code\thesadru\culturebot\_.py", line 6, in <module>
print(client.list_database_names())
File "C:\Users\D\AppData\Roaming\Python\Python39\site-packages\pymongo\mongo_client.py", line 1918, in list_database_names
for doc in self.list_databases(session, nameOnly=True)]
File "C:\Users\D\AppData\Roaming\Python\Python39\site-packages\pymongo\mongo_client.py", line 1899, in list_databases
res = admin._retryable_read_command(cmd, session=session)
File "C:\Users\D\AppData\Roaming\Python\Python39\site-packages\pymongo\database.py", line 755, in _retryable_read_command
return self.__client._retryable_read(
File "C:\Users\D\AppData\Roaming\Python\Python39\site-packages\pymongo\mongo_client.py", line 1460, in _retryable_read
server = self._select_server(
File "C:\Users\D\AppData\Roaming\Python\Python39\site-packages\pymongo\mongo_client.py", line 1278, in _select_serverer
server = topology.select_server(server_selector)
File "C:\Users\D\AppData\Roaming\Python\Python39\site-packages\pymongo\topology.py", line 241, in select_server
return random.choice(self.select_servers(selector,
File "C:\Users\D\AppData\Roaming\Python\Python39\site-packages\pymongo\topology.py", line 199, in select_servers
server_descriptions = self._select_servers_loop(
File "C:\Users\D\AppData\Roaming\Python\Python39\site-packages\pymongo\topology.py", line 215, in _select_servers_loop
raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: cluster0-shard-00-02.whzdc.mongodb.net:27017: timed out,cluster0-shard-00-00.whzdc.mongodb.net:27017: timed out,cluster0-shard-00-01.whzdc.mongodb.net:27017: timed out, Timeout: 30s, Topology Description: <TopologyDescription id: 60f00e93a72f19041df4afa6, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('cluster0-shard-00-00.whzdc.mongodb.net', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('cluster0-shard-00-00.whzdc.mongodb.net:27017: timed out')>, <ServerDescription ('cluster0-shard-00-01.whzdc.mongodb.net', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('cluster0-shard-00-01.whzdc.mongodb.net:27017: timed out')>, <ServerDescription ('cluster0-shard-00-02.whzdc.mongodb.net', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('cluster0-shard-00-02.whzdc.mongodb.net:27017: timed out')>]>
The same error is raised even for other operations.
I have attempted to search around for a solution. Most of them consisted of using different parameters for the client or adding parameters to the query of the connection string, all of which yield the same result.
I have of course added both my IP and 0.0.0.0
to the network access.
Versions:
- python 3.9.0
- pymongo 3.11.4
Any directions would be appreciated, I can always provide more info.