Mongodb – Mongoimport ‘error connecting to db servers’ for cluster

mongodb

I'm unable to use mongoimport to load some documents to a cluster hosted by MongoDB. I followed this tutorial Load File with mongoimport and then used this command in Powershell to try and load my documents:

.\mongoimport.exe --host "mongodb://clusterads-shard-00-00-qlf9n.mongodb.net:27017,clusterads-shard-00-01-qlf9n.mongodb.net:27017,clusterads-shard-00-02-qlf9n.mongodb.net:27017/admin?replicaSet=ClusterADS-shard-0" --ssl -u <USER> -p '<PASSWORD>' --authenticationDatabase <AUTHENT> --db adscoursework --collection volcanos --drop --jsonArray --file C:\data\volErups.json

This gives the error:

[........................] adscoursework.volcanos       0B/844KB (0.0%)
[........................] adscoursework.volcanos       0B/844KB (0.0%)
Failed: error connecting to db server: no reachable servers

I can connect to the above host using Mongo Shell so I don't understand where the issue is.

Best Answer

Replacing mongodb:// at the start with ClusterADS-shard-0/ (which is the replica set) and removing /admin?... made it work.