title: Pymongo pymongo.errors.ServerSelectionTimeoutError when using example code
body: <p>I am trying to run very straightforward code to figure out how to use pymongo with the MongoDB Atlas Cloud.</p>
  
  <p>Here is the example code</p>
  
  <pre><code>import pymongo
  
  client = pymongo.MongoClient("mongodb+srv://{myusername}:{mypassword}@cluster0-uywu8.mongodb.net/test?retryWrites=true&amp;w=majority")
  db = client.BroadwayMatch
  print(db)
  collection = db.Artists
  print(collection)
  
  print(collection.insert_one({'x': 1}))
  </code></pre>
  
  <p>BroadwayMatch and Artists are existing databases and collections that I was able to insert to last week, I am not sure what changed. It seems to be connecting to the database and collection successfully, but for some reason is unable to read or write to it. All attributes of collections can be accessed, but all methods result in a ServerSelectionTimeoutError. Here is the output from this snippet</p>
  
  <pre><code>Database(MongoClient(host=['cluster0-shard-00-01-uywu8.mongodb.net:27017', 'cluster0-shard-00-00-uywu8.mongodb.net:27017', 'cluster0-shard-00-02-uywu8.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, authsource='admin', replicaset='Cluster0-shard-0', ssl=True, retrywrites=True, w='majority'), 'BroadwayMatch')
  Collection(Database(MongoClient(host=['cluster0-shard-00-01-uywu8.mongodb.net:27017', 'cluster0-shard-00-00-uywu8.mongodb.net:27017', 'cluster0-shard-00-02-uywu8.mongodb.net:27017'], document_class=dict, tz_aware=False, connect=True, authsource='admin', replicaset='Cluster0-shard-0', ssl=True, retrywrites=True, w='majority'), 'BroadwayMatch'), 'Artists')
  Traceback (most recent call last):
    File "C:\Python37\Spotify-Match\mongotest.py", line 10, in &lt;module&gt;
      print(collection.insert_one({'x': 1}))
    File "C:\Python37\lib\site-packages\pymongo\collection.py", line 700, in insert_one
      session=session),
    File "C:\Python37\lib\site-packages\pymongo\collection.py", line 614, in _insert
      bypass_doc_val, session)
    File "C:\Python37\lib\site-packages\pymongo\collection.py", line 602, in _insert_one
      acknowledged, _insert_command, session)
    File "C:\Python37\lib\site-packages\pymongo\mongo_client.py", line 1279, in _retryable_write
      with self._tmp_session(session) as s:
    File "C:\Python37\lib\contextlib.py", line 112, in __enter__
      return next(self.gen)
    File "C:\Python37\lib\site-packages\pymongo\mongo_client.py", line 1611, in _tmp_session
      s = self._ensure_session(session)
    File "C:\Python37\lib\site-packages\pymongo\mongo_client.py", line 1598, in _ensure_session
      return self.__start_session(True, causal_consistency=False)
    File "C:\Python37\lib\site-packages\pymongo\mongo_client.py", line 1551, in __start_session
      server_session = self._get_server_session()
    File "C:\Python37\lib\site-packages\pymongo\mongo_client.py", line 1584, in _get_server_session
      return self._topology.get_server_session()
    File "C:\Python37\lib\site-packages\pymongo\topology.py", line 434, in get_server_session
      None)
    File "C:\Python37\lib\site-packages\pymongo\topology.py", line 200, in _select_servers_loop
      self._error_message(selector))
  pymongo.errors.ServerSelectionTimeoutError: connection closed,connection closed,connection closed
  </code></pre>
  
  <p>I'm not sure what I am doing wrong, can anyone help?</p>