'Error when trying to create dump of mongodb database

i tried to create a dump of a mongodb database on remote server which is running centos,nginx,mongodb v4.0.18 using the following command..

mongodump --host localhost:27017 --authenticationDatabase admin --username <uname> --password <password> --db <db> --out <path to dump>

but im getting the following error Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.



Solution 1:[1]

I just replaced --host localhost:27017 for --port 27017. My db is in localhost too. I omitted --db <db> --out <path to dump> too. I point to my db with the --authenticationDatabase flag.

I hope this helps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jorge V.