The “No such host is known” error appears when an invalid value is used for the Server connection property.
The first step is ensuring the host name or IP address is valid. MongoDB Compass is a great tool for running connection tests.
For MongoDB Atlas users, this error often occurs when the shard value is excluded.
On Atlas, the server property should look like this: cluster0-shard-00-00-test.mongodb.net
To find your shard value:
1. Login to the Atlas Portal.
2. Click on a project name.
3. On the left-hand pane, click on Database.
4. Click on the cluster you wish to use (Cluster0 for example).
5. You should now see a list of shards under the Region section. Hover over the shards to reveal the full value (the format is: cluster0-shard-00-00-test.mongodb.net):
It is recommended to use the primary shard for the server property. The secondary shards can be applied under the ReplicaSet property.
Do not include the port value (usually 27017) in the Server property. This should instead be set under the Port connection property.
You can read more about shard values here: MongoDB Sharding
Atlas connection documentation can be found here: DBaas Connections
Full driver documentation can be found here: MongoDB Docs
For any additional questions, please contact [email protected]