2

I have created a mongoDB cluster in documentDB. I tried connecting to the cluster from my local machine through mongoclient from pymongo.

cluster endpoint=mongooi.cluster-abcdefghij.us-east-2.docdb.amazonaws.com

client=pymongo.Mongoclient("mongodb://USER:PASSWORD@mongooi.cluster-abcdefghij.us-east-2.docdb.amazonaws.com:27017/?ssl=true&ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false*")

print(client.database_names())

I get ServerSelectionTimeoutError: mongooi.cluster-abcdefghij.us-east-2.docdb.amazonaws.com:27017: timed out

1 Answer 1

4

DocumentDB clusters are network-secure by default, so the endpoint you get cannot be reach directly from your local machine. For that, you need to have a tunnel via an EC2 server. You can find guidelines in the following link:

https://docs.aws.amazon.com/documentdb/latest/developerguide/connect-from-outside-a-vpc.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.