Welcome to the MongoDB Community @Aditya_Bhatia !
Please provide some more details about your environment:
- Type of deployment you are trying to connect to (standalone, replica set, sharded cluster)
- version of PyMongo used
- version of MongoDB server
- is this a self-hosted deployment or a managed service like MongoDB Atlas?
- example of your MongoClient connection set up (with any private credentials like username/password/hostnames replaced with placeholders)
You may also find some helpful resources via Error: couldn't connect to server 127.0.0.1:27017 - #16 by Stennie.
Regards,
Stennie