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)

Gen AI apps are built with MongoDB Atlas

Gen AI apps are built with MongoDB Atlas

MongoDB Atlas is the developer-friendly database for building, scaling, and running gen AI & LLM apps—no separate vector DB needed. Enjoy native vector search, 115+ regions, and flexible document modeling. Build AI faster, all in one place.

Start Free

👋 Kindness is contagious

Explore this insightful piece, celebrated by the caring DEV Community. Programmers from all walks of life are invited to contribute and expand our shared wisdom.

A simple "thank you" can make someone’s day—leave your kudos in the comments below!

On DEV, spreading knowledge paves the way and fortifies our camaraderie. Found this helpful? A brief note of appreciation to the author truly matters.

Let’s Go!