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.

A timeout occured after 30000ms selecting a server using CompositeServerSelector

Add “?connect=replicaSet” to the end of your connection string if connecting to MongoLab. new MongoClient(“mongodb://username:password@ds011111.mongolab.com:11111/db-name?connect=replicaSet”) This JIRA ticket has some details: https://jira.mongodb.org/browse/CSHARP-1160 Basically the default is to connect to a replica set member. But MongoLab’s Single-Node settings are actually a single node replica set and this causes us to not trust it. Appending ?connect=replicaSet to … Read more