How to Connect Flask-mongoengine to MongoDB Atlas

I’m very new to MongoDB. I am creating a Flask app with flask-mongoengine hopefully connected to a mongodb atlas cluster. I haven’t been able to connect (each time I try I get ServerSelectionTimeoutError).

This is in my config.py:

MONGODB_HOST = “mongodb+srv://:@/test?retryWrites=true&w=majority”

Thanks in advance!

Welcome to Community!

Are you able to connect with shell using your SRV connect string?
Don’t see userid/pwd placeholders in your string
Can you ping your cluster?

Connect string should look like below format
mongodb+srv://userid:password@clustername.xxx.net/test?retryWrites=true&w=majority

When trying to connect the shell, it didn’t connect:

@(connect):2:6
exception: connect failed```
0.0.0.0/0 is whitelisted

I’ll try the shell method right now

Sorry, I removed the user id, password, and clustername for security purposes. What address should I try to ping? clustername.xxx.net/test ?

Were you able to connect by shell?

ping your cluster something like below based on your cluster name
ex:ping sandbox-shard-00-00-xyz.mongodb.net