How to connect MongoDB with MongoDB Compass

Configuring a MongoDB to allow remote connection (bindIP)

Note: Please make sure you mongodb service is running and if firewall is installed in your server please make sure you have allowed the 27017 port on the firewall.

Now you need to make changes in /etc/mongod.conf to allow remote connection.
To allow remote connections, you must edit the MongoDB configuration file  /etc/mongod.conf  in configuration file look for the bindIp parameter and make sure it is set to either 0.0.0.0 (to allow all IP addresses) or the specific IP address of your server.
For exmple:-

image

Here we set bindIp: 127.0.0.1, 2.2.2.2 please add IP address of the server on which you’ve installed MongoDB here we have added dummy ip 2.2.2.2.
If you want to allow all ipv4 and ipv6 Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses.

Now restart MongoDB service

Now we can connect MongoDB with MongoDB Compass

Open MongoDB Compass and click on new connection add IP of your server and click on  the Authentication option becuse the server was secured with authentication enabled you need to enter your administrative MongoDB user’s username, the password.

image

After selecting this you need to select Authentication and then select Username/Password and add administrative MongoDB user’s Username and password.
Administrative MongoDB user password are store at /var/webuzo/mongodb.conf

In the Authentication Database (optional) filed you need to add "admin" because in webuzo the default authentication database is admin.

image

Now click on connect.

image

Once the connection is succeeds it will showing the list of all the databases.

Was this page helpful?