How to escape @ in a password in pymongo connection?

You should be able to escape the password using urllib.quote(). Although you should only quote/escape the password, and exclude the username: ; otherwise the : will also be escaped into %3A. For example: import pymongo import urllib mongo_uri = “mongodb://username:” + urllib.parse.quote(“p@ssword”) + “@127.0.0.1:27001/” client = pymongo.MongoClient(mongo_uri) The above snippet was tested for MongoDB v3.2.x … Read more

Why is PyMongo 3 giving ServerSelectionTimeoutError?

We’re investigating this problem, tracked in PYTHON-961. You may be able to work around the issue by passing connect=False when creating instances of MongoClient. That defers background connection until the first database operation is attempted, avoiding what I suspect is a race condition between spin up of MongoClient’s monitor thread and multiprocess forking.