Skip to content
Advertisement

How to connect to Mongo database locally using python

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?

this my 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()

error:

ConnectionFailure: could not connect to localhost:27017: [Errno 10061] No connection     could be made because the target machine actively refused it

Advertisement

Answer

Refer this PyMongo Connection to connect and Connection is deprecated

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement