DEV Community

Cover image for MongoDB Compass connection issue
Z. QIU
Z. QIU

Posted on

MongoDB Compass connection issue

I am working on migration of our Data Warehouse project from Alibaba Cloud to Huawei Cloud this week. All goes well, except one issue occurs when I tried to connect to MongoDB using MongoDB Compass Community.

As I have presented in my previous post, I have deployed MongoDB service using docker and I have successfully connected to my MongoDB database from IPython console. So I firstly tried again the visit from Ipython today to make sure that the MongoDB service is still running on Huawei ECS. It IS still working well:

Alt Text

Then I open MongoDB Compass Community and fill the login information as below (our domain name has not yet been authorized so I have to use Ip address for hostname):
Alt Text
However, when I click "CONNECT" button, nothing happens.

After a close investigation, I found the reason. After I filled all the fields for connection, Compass yielded a connection URI string as below.
Alt Text

In fact, as explained in official manual of MongoDB, the standard URI syntax for connection is as mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]. Thus in my case, the Compass software has strangely used ip:port as the Database name to visit. Since there is no database with such name, so it shall do nothing and stays in the connection interface.

Now I correct the URI string manually and fill my database name into this string as below and it works:
Alt Text

Once I click "CONNECT", Compass jumps to display interface of the queried database now:
Alt Text

Top comments (0)