M121 - Chapter 4 - MongoImport failure for companies.json

I am trying to import the companies.json provided with the Chapter 4, but encountering failure.

I am able to connect to MongoDB atlas cluster using the following command (works fine) -

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/aggregations?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

However, if I use the same URI for the mongoimport command, I am facing connection issues.

mongoimport --uri="mongodb://m121:aggregations@cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/?replicaSet=Cluster0-shard-0" --drop ./companies.json --authenticationDatabase admin --ssl


2021-08-28T18:32:54.175+0530 no collection specified
2021-08-28T18:32:54.175+0530 using filename ‘companies’ as collection
2021-08-28T18:33:12.373+0530 error connecting to host: could not connect to server: connection() error occured during connection handshake: dial tcp: i/o timeout

Any inputs or information no how to solve this issue.?


Why do you want to import to Class cluster m121 user is having read only access to aggregations DB

You should use your own cluster to import data or use your local mongod instance

Try to use SRV string with --uri option or use --host option on appropriate cluster/DB where you have R/W privileges