Connection to Cluster not working


I am trying to connect to Atlas using NodeJs.
My code is as below.


It gives me timed out error in Compass.
In the code, it gives me the following error.

“Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you’re trying to access the database from an IP that isn’t whitelisted. Make sure your current IP address is on your Atlas cluster’s IP whitelist:

I have whitelisted the ip address so that it can be accessed from every where.

Can you please guide me what is wrong here?



Can you connect by shell?

As an alternative you can fill individual fields for connection and try for Compass