title: pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused django to heroku
body: <p>I'm using django with mongodb atlas and trying to deploy using heroku. Somehow I keep facing <code>pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused</code> this error. </p>
  
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'djongo',
          'NAME': 'name',
          'HOST': 'mongodb+srv://user:pass@cluster0-xb9zh.mongodb.net/test?retryWrites=true&amp;w=majority',
          'USER': 'user',
          'PASSWORD': 'pass',
          }
      }
  </code></pre>
  
  <p>For django setting.py I simply changed it from <code>sqlite</code> to mongodb. It works perfectly in my local. There is one change I am suspicious is I had to change a <code>mongo_client.py</code> file from localhost to the connection string in order to make my mongodb connect to atlas instead of my local database. Not sure if that has anything to do with this.</p>
  
  <pre><code>class MongoClient(common.BaseObject):
      """
      A client-side representation of a MongoDB cluster.
  
      Instances can represent either a standalone MongoDB server, a replica
      set, or a sharded cluster. Instances of this class are responsible for
      maintaining up-to-date state of the cluster, and possibly cache
      resources related to this, including background threads for monitoring,
      and connection pools.
      """
      HOST = "mongodb+srv://user:pass@cluster0-xb9zh.mongodb.net/test?retryWrites=true&amp;w=majority"
      PORT = 27017
      # Define order to retrieve options from ClientOptions for __repr__.
  
  </code></pre>