Mongoose failed to connect and Atlas MongoDB expect to whitelist IP while all IP has allowed help

“await” might do some tricks. and you may not need to wrap depending on project type ("type":"module")

Anyways, I guess I could wrap your above code correctly. I just had to comment out loadmodules and IIFE block at the end.

took me a while to adapt missing parts and some “import” issues, but it does connect to my cluster with no problem.