title: Getting error: "localhost:27017: [Errno 111] Connection refused" while connecting to mongoDB on Heroku but works fine on my computer
body: <p>I'm using PyMongo. Everything works fine and can connect fine to MongoDB, that's on my computer but when I put the scripts on GitHub and run them through Heroku for my Discord bot I keep on getting the error saying:</p>
  
  <blockquote>
    <p>pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused</p>
  </blockquote>
  
  <p>I don't know why this happens while it works fine on my computer, I put <code>pymongo</code> in <code>requirements.txt</code>. Below is how I connect to MongoDB (with PyMongo):</p>
  
  <pre class="lang-py prettyprint-override"><code>import pymongo
  from pymongo import MongoClient, ReturnDocument
  dbclient = MongoClient('mongodb://localhost:27017/')
  # On Heroku I get error:"localhost:27017: [Errno 111] Connection refused"
  </code></pre>