MongoDB connection error: MongoTimeoutError: Server selection timed out after 30000 ms

Solution 1:

just go to mongodb atlas admin panel.Go in security tab>Network Access> Then whitelist your IP by adding it

See this image to locate the particular menu

Note:Check your IP on google then add it

Solution 2:

Sometimes this error occurs due to the IP Address given access to in our database.

Mind you, your application can be working well then come up with such an error. Anytime this happens, most times your IP address has changed, which is not on the whitelist of addresses allowed. (IP addresses can be dynamic and are subject to change)

All you have to do is to update the whitelist with your current IP addresses

Solution 3:

Ensure that the "<" and ">" are removed when you replace the user and password fields. This worked for me