title: How to connect to Mongo database locally using python
body: <p>I am using ipython 2.7. I am creating database name enron in mongodb. I have tried to connect to this database locally but the following error occurred - how do I fix it?</p>
  
  <p>this my code:</p>
  
  <pre><code>import json
  import pymongo  # pip install pymongo
  from bson import json_util 
  from pymongo import MongoClient# Comes with pymongo
  conn = pymongo.Connection('mongodb://user:user123@localhost27017.mongolab.com:33499/enron')
  client = MongoClient()
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>ConnectionFailure: could not connect to localhost:27017: [Errno 10061] No connection     could be made because the target machine actively refused it
  </code></pre>