MongoDB cloud example with Python

I am trying to pass data back and forth via Python to a free MongoDB collection that I have created with my account. I’ve populated the cluster with the sample data. I am trying to access the documents within the shipwrecks collection. The error that I receive is:

pymongo.errors.ServerSelectionTimeoutError: [WinError 10061] No connection could be made because the target machine actively refused it,

Here is my code. I have removed my password on purpose. Please help.

import pymongo

cluster = pymongo.MongoClient(“mongodb+srv://”)

db = cluster[“sample_geospatial”]
collection = db[“shipwrecks”]

results = collection.find_one()



Hi @Mark_Woodmansee, have you remembered to whitelist your machine’s IP address in the Atlas settings? Forgetting to do that is generally the cause of the error you’re getting.

1 Like