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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…