MongoDB and Mongoose - Create and Save a Record of a ModelMongoDB and Mongoose - Create and Save a Record of a Model error timeout has occured

I am getting the error timeout has occured


any help will be appreciated

Somebody plssssssssssssssss help

Hi, I’ve noticed that you are using starter file from Node section and not the starter file from MogoDB section. Maybe that could be the problem?

I don’t understand?!?!?!?!

I dont think that is the problem because i did click on that llink

when i started these tests

@orvalho
Can you please post the solution as I have been stuck on this for 20 days!
:pleading_face:

Looked into your code. Noticed that your app isn’t connected to DB.

You can check connection like so:

console.log(mongoose.connection.readyState);

ready states being:

  • 0: disconnected
  • 1: connected
  • 2: connecting
  • 3: disconnecting

So the problem is that your app isn’t connected to DB.
One possible solution: check your .env file - did you replaced <password> with actual password?

No i did not

@orvalho
Now i am getting error item.name should be a string

When I console.log(mongoose.connection.readyState); in the logs I’m still seeing 0 (meaning DB is disconnected).

Did you whitelisted all IPs when you created the DB?

Yes
pl help i am still not able to do it

First you need to check console.log of glitch. To do, open “tools” (corner left down), and then click on “logs”.

Second verify your connection to mongoDB. You need to rewrite the connection because the news connection need an object argument. Put:

mongoose.connect(process.env.MONGO_URI, { useUnifiedTopology: true, useNewUrlParser: true });
console.log(mongoose.connection.readyState);

On console you check the logs:

  • 0: disconnected
  • 1: connected
  • 2: connecting
  • 3: disconnecting

Are you connected or connecting? well verifiy if there is another error or warning at the logs.

Hi Everyone!

I was having issues with this challenge as well. The solution for me was changing my password.

I had a password that included special characters (i.e. *!@#%&) that would be URL-encoded. Once I updated my password to only contain alphanumeric (a-z,A-Z) characters, my app could connect to my MongoDB cluster.

I hope this helps some of you!

@techCarpenter If you had special characters, did you try wrapping the entire URI in double or single quotes?

@RandellDawson I tried wrapping the URI in double quotes. I did notice that the mongoDB instructions mentioned to replace <password> with my password, but originally I was writing < my_new_password > and then after changing my password I may have taken out the angle brackets. I’ll try without the angle brackets and a password that contains special characters and see if it works.

EDIT

After changing back to a password with special characters, I still couldn’t pass the tests for this challenge, but I changed it back to a password without special characters and it worked fine.

1 Like