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

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay