I’m working on a Python program that submits data to Mongolab, and I’m running across a strange exception:
mongoengine.connection.ConnectionError: Cannot connect to database mongodb://<user>:
<password>@ds035617.mongolab.com:35617/<mydatabase>:
could not connect to localhost:27017: [Errno 10061] No connection could be made
because the target machine actively refused it
This is the offending code:
from mongoengine import *
connect('tablename', "mongodb://<user>:<password>@ds035617.mongolab.com:35617/<mydatabase>")
Anyone have any ideas as to what is wrong?
I generally think it’s poor form to answer one’s own question, but I figured out the (rather simple) answer and wanted to document it to make sure others would have it as well.
The issue was not specifying
host=as a keyword argument in theconnectfunction. The correct function call would be: