My cloud MongoDB setup was working fine at first but randomly without me making any changes to my codebase or db set up I started getting a ServerSelectionTimeoutError and connection closed error when trying to run my python application from localhost against my cloud mongoDB instance.
Everything runs fine again my local mongoDB setup but I keep getting this error when trying to run my server again my cloud DB instance.
If you’ve already done these steps perhaps your IP has changed? Try double checking the IP access rules for your cluster.
Another way to confirm would be to attempt to connect via the mongo shell from the same machine. If both mongosh and pymongo cannot connect that’s a clear indication of a network issue.