pymongo.errors.ConfigurationError: The DNS query name does not exist:

Viewed 28

I am trying to connect to mongo db from flask virtual env. But I'm getting this error pymongo.errors.ConfigurationError: The DNS query name does not exist: version python = 3.7 dnspython = 2.2.1

def establish_connection():
    app = flask.Flask(__name__)
    connection_string = "mongodb+srv://username:password@clustername.mongodb.net/?retryWrites=true&w=majority"
    app.config["MONGO_URI"] = connection_string
    mongodb_client = PyMongo(app)
1 Answers

Install the library dnspython

Then try running the file again.

Link to know more: https://pypi.org/project/dnspython/

Command to install the library:

pip install dnspython

or

pip3 install dnspython

Related