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

    XMLWordPrintable

    Details

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

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: