# Heroku mongodb deployment error React course

**URL:** <https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297>\
**Category:** React\
**Created:** [October 27, 2020, 5:31pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297 "2020-10-27T17:31:24Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![sampreeth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sampreeth/32/523_2.png) [@sampreeth](https://forum.codewithmosh.com/u/sampreeth)\
**Post date:** [January 5, 2021, 5:37am UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/11 "2021-01-05T05:37:32Z")

</div>

Steps I followed to fix this issue.

First,

```
npm update mongoose

```

Latest mongoose as of 5/01/2021 is mongoose 5.11.10. If there is a newer version please check the documentation.

Second,  
If you are following mosh course. Open db.js in startup folder.

Change

```
mongoose.connect(db)

```

to

```
mongoose.connect(db, {useNewUrlParser:true, useUnifiedTopology: true})

```

Three,  
copy the connection string for Node driver version 2.2.12 or later.

make sure the connection string does not have (mongodb+srv)

copied connection string for node driver version 2.2.12 will look like as shown below.

```
mongodb://<username>:<password>@vidlycluster-shard-00-00.knv7y.mongodb.net:27017,vidlycluster-shard-00-01.knv7y.mongodb.net:27017,vidlycluster-shard-00-02.knv7y.mongodb.net:27017/<dbname>?ssl=true&replicaSet=atlas-8ezfa5-shard-0&authSource=admin&retryWrites=true&w=majority

```

Replace “password” with the password for the “username” user. Replace “dbname” with the name of the database that connections will use by default.  
Once replaced, remove all the angle brackets.

Four,  
Head over to heroku dashboad,  
→Settings → Click on “Reveal Config Vars” → Enter the Key as vidly\_db, value will the connection mongodb connection string.

Five,  
Back to terminal,  
git add .  
git commit -m “Commit message”  
git push heroku master  
heroku open

Hope this helps someone. It was a struggle for me to find this solution.

Cheers.

Ps: @Mosh Mlab is now bought by mongodb atlas. If you could update this in your course it would be really grateful.

---

_[View the full topic](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297)._
