If you're using a hosted service (like MongoDB Atlas), make sure you've set up the IP white-list so that it isn't blocking your IP address. You can set it to 0.0.0.0/0 to whitelist all IP addresses, but this is a bad idea in terms of security so it should only be used as a temporary measure.