URL Shortener Mongoose readyState 0

Mongoose is not connecting to MongoDb atlas. I have already whitelisted all the ip addresses.


I have written the correct username and password.

Glitch url- https://glitch.com/~twilight-headline

I’m a newbie so any advise is appreciated.

I didn’t use quotes and I had to delete

from the end of it for me to get it to work. I haven’t looked into the purpose of what that part at the end does. A quick guess is it tries to rewrite to the database if it fails the first write. But, anyway, I couldn’t connect to the db until I deleted that part.

Thanks for the feedback! I removed the quotes and deleted the part at the end but I am still unable to connect to MongoDb Atlas, the mongoose readyState is still 0. Maybe the problem is in my MongoDb cluster? Should i message you my Mongo_uri?

I used:

and connected this way:

mongoose.connect(process.env.MONGO_URI, {
  useMongoClient: true

but I just started with database-stuff so I’m not sure about that…

What version of mongo and mongoose are you using? This also makes a difference. I used

		"mongodb": "^3.2.7",
		"mongoose": "^5.6.0",

Thanks a lot eoja! I used your versions and it started working!

1 Like

Thanks this worked for me. I would have thought that the default version included on the cloned project would work out of the box but I guess not.

1 Like