Error: querySrv ENOTFOUND _mongodb._tcp.dbname.fzofb.mongodb.net
The error indicates that there is no error in the code. This leaves you with three potential possibilities:
- Ensure you have MongoDB installed on your computer.
- Make sure you're connected to wifi that is not public.
- Make sure you have allowed the IP in network access of MongoDB as shown in the image below:
In my case, I was connected to public wifi in a coworking space. I change my connection to my personal hotspot and it worked.
Also if you have your mongodb Atlas cluster inactive after a while. It could get paused and then when you run a server it returns the error you had.
So another bet is to login to your Atlas account and confirm if it hasn't been paused. Well this option of mine should only be considered after trying the options above.