# URL Shortener Mongoose readyState 0

**URL:** <https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466>\
**Category:** General\
**Created:** [July 15, 2019, 6:07pm UTC](https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466 "2019-07-15T18:07:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![utkarshnag](https://avatars.discourse-cdn.com/v4/letter/u/dfb087/32.png) [@utkarshnag](https://forum.freecodecamp.org/u/utkarshnag)\
**Post date:** [July 15, 2019, 6:07pm UTC](https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466/1 "2019-07-15T18:07:50Z")

</div>

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

`MONGO_URI='mongodb+srv://<username>:<password>@cluster0-ik0df.mongodb.net/test?retryWrites=true&w=majority'`

I have written the correct username and password.

Glitch url- [https://glitch.com/~twilight-headline](https://glitch.com/~twilight-headline)

I’m a newbie so any advise is appreciated.

---

<div class="post-metadata">

**Author:** ![eoja](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/eoja/32/135387_2.png) [@eoja](https://forum.freecodecamp.org/u/eoja)\
**Post date:** [July 15, 2019, 6:17pm UTC](https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466/2 "2019-07-15T18:17:04Z")

</div>

I didn’t use quotes and I had to delete

> [@utkarshnag](#):
>
> retryWrites=true&w=majority

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.

---

<div class="post-metadata">

**Author:** ![utkarshnag](https://avatars.discourse-cdn.com/v4/letter/u/dfb087/32.png) [@utkarshnag](https://forum.freecodecamp.org/u/utkarshnag)\
**Post date:** [July 16, 2019, 4:20am UTC](https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466/3 "2019-07-16T04:20:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![s-projects18](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/s-projects18/32/106502_2.png) [@s-projects18](https://forum.freecodecamp.org/u/s-projects18)\
**Post date:** [July 16, 2019, 4:51am UTC](https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466/4 "2019-07-16T04:51:21Z")

</div>

I used:  
`MONGO_URI='mongodb://<username>:<password>@cluster0-ik0df.mongodb.net/test?retryWrites=true&w=majority'`

and connected this way:

```auto
mongoose.connect(process.env.MONGO_URI, {
  useMongoClient: true
});

```

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

---

<div class="post-metadata">

**Author:** ![eoja](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/eoja/32/135387_2.png) [@eoja](https://forum.freecodecamp.org/u/eoja)\
**Post date:** [July 16, 2019, 5:08am UTC](https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466/5 "2019-07-16T05:08:41Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![utkarshnag](https://avatars.discourse-cdn.com/v4/letter/u/dfb087/32.png) [@utkarshnag](https://forum.freecodecamp.org/u/utkarshnag)\
**Post date:** [July 17, 2019, 3:32am UTC](https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466/6 "2019-07-17T03:32:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jt-squared](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@jt-squared](https://forum.freecodecamp.org/u/jt-squared)\
**Post date:** [July 16, 2020, 2:22am UTC](https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466/7 "2020-07-16T02:22:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 11:27am UTC](https://forum.freecodecamp.org/t/url-shortener-mongoose-readystate-0/295466/8 "2021-01-16T11:27:01Z")

</div>

Closed on January 16, 2021, 11:27am UTC


