Pymongo error Server Timeout

user3062459

I installed the latest version of Pymongo 3.2.2 using pip. Additionally I use Python 3.4 Anaconda. 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"]
>>> collection = 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)

This is the message I get at the bottom of the Traceback:

Traceback (most recent call last):

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

How can I fix this so that I can insert a record into MongoDB?

Bernie Hackett

Resolved in https://jira.mongodb.org/browse/PYTHON-1100. The issue was the machine's hosts file had localhost mapped only to IPv6 and MongoDB doesn't listen on IPv6 by default.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Protractor Selenium Standalone server is getting timeout error

From Dev

Collection object is not callable error in PyMongo with server_info()

From Dev

ObjectID generated by server on pymongo

From Dev

Pymongo connection timeout from remote machine

From Dev

Cordova 3.0, Application Error The Connection to the server was unsuccessful. (Timeout)

From Dev

PXE boot error: PXE-E18: Server response timeout

From Dev

PXE boot error: PXE-E18: Server response timeout

From Dev

Cordova 3.0, Application Error The Connection to the server was unsuccessful. (Timeout)

From Dev

SQL Server 2012 error - Lock Request Timeout exceeded

From Dev

App sudden got a Timeout exception and Internal server error

From Dev

Error while sorting in pymongo

From Dev

MongoLab/PyMongo connection error

From Dev

Collection object is not callable error with PyMongo

From Dev

Key must not contain . error in pymongo

From Dev

pymongo installation gives permission error

From Dev

Connection timeout for ssh server

From Dev

TCP Server response timeout

From Dev

Entity Framework server timeout

From Dev

Connection timeout for ssh server

From Dev

PyMongo: What happens to cursor when no_cursor_timeout=True

From Dev

Arduino: Upload Timeout error

From Dev

Storm UI timeout error

From Dev

PyDNS & DNS timeout error

From Dev

Specifically check for timeout error

From Dev

SQL error timeout with transaction

From Dev

Cordova webview TIMEOUT ERROR

From Dev

Checking for Timeout Error in python

From Dev

Timeout::Error exception in a loop

From Dev

Geopy: catch timeout error