Can't connect via URI to mongoDB

Hi,
I’m trying to connect into my installed mongoDB shell via the URI from the university course
mongo “mongodb+srv://sandboxl.72osvde.mongodb.net/myFirstDatabase” --username m001-student
Getting this error:

The URI isn’t working for me, I prefer working on my app and not from the browser,
Can someone assist please?

Is the cluster address correct?
Usually it will be like sandbox.xxxx.mongodb.net but i see sandboxl
Have you taken the correct connect string from your Atlas account?

Hi, indeed i copied the connect tab and clicked on “I have the MongoDB Shell installed”
I choose version 4.4 and also tried Mongosh
“sandboxl” is the name I choose for my database…

c:\WorkSpace\mongodbworks>mongo "mongodb+srv://sandboxl.72osvde.mongodb.net/myFirstDatabase" --username m001-student
MongoDB shell version v5.0.4
Enter password:

your connection command works fine. are you using the whole string in the terminal or copy-pasted into your app’s URI variable? for applications main URI is just this one: mongodb+srv://sandboxl.72osvde.mongodb.net

to add username/password and other details, check your app’s mongodb library’s page and this base manual.

thank you for your answer
i’m not sure what should I insert in the URI in my MongoDB shell
I tired to insert from the URL you provided some URIs but still without success

I prefer to work from the Shell so any help with this on-boarding would be amazing!
thanks

this one is exactly the one to start the shell. just open a terminal and execute it provided that “mongo” is in your system “path” (else run with full path)

Hi, i still cannot login via my own shell

I thought this would be a clear direction.

You just use the main URL, and add user and password details depending on how your app reads them.

You keep saying things like “shell” and “app”, but it gets losing its meaning now. In “exactly” what program are you trying to connect? Give more details of that “shell” you are talking about so someone who knows about it may help.

2 Likes

I’m sorry for the inconvenience, i have MongoDB on my computer which I’m using with our company DB
I want to add another connection from the connect tab
I’m trying to add the URI I provided above and it is not working for me
I tried also this:
mongodb+srv://sandboxl.72osvde.mongodb.net
and I’m getting this:

You are still not telling us what program you are using. We cannot help but speculate. Anyways, this new error implies you need to include your credentials in your program, as well as other auth requirements if needed.

So this comes to the second part of my above post:

this could be just a basic embedded way into the URI:

mongodb+srv://USERNAME:PASSWORD@sandboxl.72osvde.mongodb.net

or it could be a bit more things embedded into it, again as described in the link I gave.

Or it may even be a JSON object you need to write:

{   "URI": "mongodb+srv://sandboxl.72osvde.mongodb.net",
   "username":"USERNAME",
   "password": "PASSWORD"
}

Whatever the shape is, the ones who have the actual answers are those familiar with that program. Since you are still cryptic about it you will be very lucky if someone here in the forums can tell what it is from the limited info you provided.

The fastest way for you would be to find whoever wrote that program, whoever gave you that program, whoever forces you to use that program, and then ask them how to enter credentials (username/password at least) into it along with other details if needed.

3 Likes

Resolved, with the Username+Password
I’m not searching for the fastest way but to understand how it works, No one forced me to use this program lol, just some labor pains

Thanks

This is my connect string

mongo “mongodb+srv://m001-student:m001-mongodb-basics@cluster0.mongodb.com/admin”

It fails with DNSRecordTypeMismatch. A Domain name cannot start with a ’ . ’

The other URI here has an extra entry after the db cluster name. Where do I get that?

when I changed the .com with .net, it complains that DNSHostNotFound. Failed to look up service.

I finally found my connect string at the very beginning I missed it

mongo “mongodb+srv://m001-student:m001-mongodb-basics@cluster0.mf7icxd.mongodb.net/admin”

Atlas connection string includes the “clustername” you have given during setup, a “random name” given by Atlas itself to your cluster, and then “mongodb.net

mongodb+srv://clustername.randomname.mongodb.net

Login to your Atlas account and go to your cluster view. There you will see the “connect” button and you will find a full URI to connect to your cluster.

add username/password and other details as we discussed above.