Can not connect to mongodb locally: Server selection timed out after 30000 ms

Thanks for showing the output of the commands @mahmoud_abdelfatah. In playing around, I was able to get a similar timeout message while trying to connect to a local replica set using Compass if my replica set name was incorrect. Have you validated that you are using the correct name?

You can check the name of the replica set by connecting directly to one member of the set and looking to see what information is provided in the upper left box in Atlas:

image

If that name (foo) in the example above matches the value you’re typing in for the replicaSet parameter, then I’m not sure why you’re still timing out.