TypeError: Cannot read property 'close' of undefined

I have seen few links with the same topic, still I am posting this as I feel this has something else to do.
I am facing this issue quite often, its not during the start of the project its somewhere in the middle while I am close to end Chapter 2.

image

Here is one point that I am not able to understand, after setting up the folder structure I have come till Chapter 2 - Get Comments, now I faced this issue again without making any changes to .env.
Is this because we are using free account & it has some limit?

Then I tried to start the project to check if its working fine & faced below issue…

Error: querySrv ESERVFAIL _mongodb._tcp.sandbox.x1gfz.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:203:19)

Upon checking, found https://github.com/Automattic/mongoose/issues/8811

So, right now I am not able to connect to my application too.

I have check the DNS definition for your cluster and it looks okay. Your internet or vpn provider might be using old DNS servers. Try using 8.8.8.8 from google.

I had this problem, I t changed the connectTimeoutMS variable in mongoclient.spec.js to 2000 (this is defined twice in the file. make sure to change the expected().toBe() to match the number.

This worked for some people, it didn’t work for me.

I rechecked my DNS settings, and statically set it to 1.1.1.1 and 1.0.0.1 on my computer. I had previously had it pointing to my router (dhcp), which my ISP, in its infinite wisdom, changed to its own shoddy DNS in an update. That worked.