Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1100

pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 8] nodename nor servname provided, or not known

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Environment:
      Pymongo 3.2.2
      Python 3.4 Anaconda
      MongoDB 3.0.6

      I am trying to do a simple insert. Here is my code:

      >>> from pymongo import MongoClient
      >>> client = MongoClient(connect=False)
      >>> client["mydb"]
      Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'mydb')
      >>> db = client["mydb"]
      >>> db["mycollection"]
      Collection(Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'mydb'), 'mycollection')

      >>> book = {}
      >>> book["title"] = "AnyBook"
      >>> book["Author"] = "AnyAuthor"

      >>> collection.insert(book)

      Traceback (most recent call last):

      pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 8] nodename nor servname provided, or not known

      Additionally, I have tried it without passing any parameters, i.e., MongoClient()
      and have also pip installed version pymongo version2. Neither which has worked. No one on stackoverflow seems to know.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            darchcruise Jason Darcy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: