sadaf2605
sadaf2605

Reputation: 7540

mongo connection failed when I have made connection through pymongo

I am using this for insertion:

import pymongo
import sys

def main():
    connection = pymongo.Connection("mongodb://localhost", safe=True)

    db = connection.m101
    people = db.people

    person ={'name': 'Barack Obama', 'role':'President',
             'address':{'address1': 'The White House',
                        'street': '1600 Pensylvania Avenue',
                        'state':'DC',
                        'city':'Washington'},
             'interests':['government', 'basketball', 'the middle east']

        }

    people.insert(person)

And when I try to use writing mongo command it says

Could not connect to server 127.0.0.1:27017 src/mongo
shell mongo.js:91
exception: connection failed

What can be done? I am following their tutorial!

Upvotes: 1

Views: 1173

Answers (1)

arjunaskykok
arjunaskykok

Reputation: 956

You need to run mongo daemon server.

$ mongod

You can look more information here: Is mongodb running?

Upvotes: 2

Related Questions