Mongodb and mongoos backend

what does this error mean:
errno: undefined,
code: ‘ETIMEOUT’,
syscall: ‘queryTxt’,
hostname: ‘cluster0.b6hdqpq.mongodb.net
}

the bad thing is that i cant connect and cant pass let me try ill give you feedback

it did not work i even tried changing ip address but nothing

The information you’ve given so far is kind of broad, and it would be nice to have some more details. Which project or course are you stuck on? Can you provide a link to your project code, or paste it in this post?

My first question to you would be: How are you connecting to your database with mongoose?

Does the URI string in your environment file resemble something along the line below?

mongodb+srv://<username>:<password>@cluster0.b6hdqpq.mongodb.net/? ...

Obviously don’t post your db credentials. If I was getting that error personally, I’d try referring back to the MongoDB Atlas Tutorial first.

I hope this can be of some help.

please ihv tried every possible way which i know of still nothing works its giving me same error

yes it resembles to that one:
mongodb+srv://moshe_david_27:@cluster0.b6hdqpq.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0

Which freeCodeCamp course, or project are you stuck on? Have you been able to complete other freeCodeCamp courses or projects that use MongoDB, and Mongoose?

Can you please provide some code, or a link to your current code? (Excluding your database credentials)

It’s hard to determine what your issue is, and how to attempt to help you without some more information

im stuck on MongoDB and Mongoose on section 2/10 which is create and save a record of a model
plus the solution on the code of the get help section is out of date since mongodb doesnt accept callback so i had to use chatgpt to fix the code which it passed but the issue of not connection of mongodb still persists.
im using local on my computer since my gitpod is out of credits.


look at this pic

Thank you for sharing which course and lesson your having issues with.

Could you share the code from the .js file in which you set up Mongoose, created a ‘Person’ model, and then attempt to create and save a person to your database?

I know you shared some of the error that was output to the console in your initial post, but would you mind posting the console output for the entire error you are receiving when you try and start your server?

Edit:
Also, looking at the photo you just posted. Are you adding that URI string to your .env file? You should only need to copy that string, you don’t need to do any further connection from there.

Edit Again:
Did you follow the steps for running MongoDB Atlas from the cloud? I never needed to run MongoDB, or connect locally to the database like the image you show. The connection address you receive when you establish your new database on mongodb.com should be the string you use for your MONGO_URI parameter in your .env file.


i did just like they said in the instructions

Try enclosing your MONGO_URI address in quotes as a string. Like so:

MONGO_URI='uri_string'

That doesn’t seem to be the issue though. Because you’re running your server locally versus on gitpod, you might be facing a DNS issue. I know you said you changed an ip address trying to solve the problem. There is a thread on stackoverflow that seems to reflect your same issue. Check it out here if you already haven’t.

You can try a VPN or a different DNS service (Google, Cloudflare, etc.). It is most likely something with your local network.

I might suggest you try to use Gitpod, Replit, or Glitch and see if that doesn’t help. I know it has worked for others that had the same issue running locally.

yes it was i used glitch and it passed thanks so much for help it worked perfectly fine

1 Like