I am unable to connect Atlas MongoDB while using --host
option, But i’m able to connect while using --uri
option where did i made a mistake?
For example:
–uri option It’s working fine
mongodump --uri="mongodb+srv://<username>:<password>@<hostname>/<dbname>" --gzip --out=/dir1/dir2
–host option getting error like
Failed: error connecting to db server: no reachable servers
mongodump --host <hostname>:<port> --username <username> --password <password> --authenticationDatabase <dbusername> --gzip --db <dbname> --out /dir/dir2
2
Answers
As you can see here, if you connect using
--uri
you use a MongoDB URI resource (starting withmongodb://
)But if you use
--host
you don’t, as this is not a MongoDB URI:Source: mongodump docs
Based on comment you can try this:
You may need to specify the authentication database:
See Authentication failure while trying to save to mongodb