I've had similar issue like this, but in my case, what I had to do was to go to mongoDB atlas network access settings and to make sure my IP address is whitelisted, that is, allowed.