To allow remote connections, you must edit the MongoDB configuration file — /etc/mongod. conf — to additionally bind MongoDB to your server's publicly-routable IP address.
This way, your #MongoDB installation will be able to listen to connections made to your MongoDB server from remote machines.
To Enable mandatory authentication in MongoDB:
If you are using the legacy MongoDB configuration format, add the auth key to /etc/mongod.conf : auth=true.
If you are using the current MongoDB configuration format, add the security.authorization key to /etc/mongod.conf : security: authorization: enabled.
This tutorial walks you through configuring a MongoDB installation on #Ubuntu to securely allow access from a trusted remote computer:
https://ibmimedia.com/blog/175/mongodb-remote-access-configuration-for-ubuntu