# 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:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![roshin](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@roshin](https://forum.codewithmosh.com/u/roshin)\
**Post date:** [October 27, 2020, 5:31pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/1 "2020-10-27T17:31:24Z")

</div>

I get an error when trying to connect heroku to mongodb atlas. In the logs, I do see a message on connection to db being successful but the following error happens:  
MongoError: (Unauthorized) not authorized on admin to execute command { listIndexes: “users”, cursor: { }, $clusterTime: { clusterTime: {1603819118 3}, signature: …

It appears this was posted once in the forum but it can no longer be found. Any help to fix this would be greatly appreciated.

Thanks,  
Roshin

---

<div class="post-metadata">

**Author:** ![hakuhal](https://avatars.discourse-cdn.com/v4/letter/h/b19c9b/32.png) [@hakuhal](https://forum.codewithmosh.com/u/hakuhal)\
**Post date:** [October 28, 2020, 8:11am UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/2 "2020-10-28T08:11:27Z")

</div>

It seems you use node.js 3.0 version, use node.js 2.2.12  
heroku cannot understand “srv+mongodb://…" use “mongodb://…” instead

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/1X/d352948efd3c0bb284fc49c641e62ca3da23c81e.png)

---

<div class="post-metadata">

**Author:** ![roshin](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@roshin](https://forum.codewithmosh.com/u/roshin)\
**Post date:** [October 28, 2020, 11:18pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/3 "2020-10-28T23:18:23Z")

</div>

Dear Hakuhal,

Thank you for your reply. It worked, I can connect and I see no errors! I was afraid if M0 free cluster limitations were the problem but that does not appear to be the case.

Really appreciate it,

Roshin

---

<div class="post-metadata">

**Author:** ![hakuhal](https://avatars.discourse-cdn.com/v4/letter/h/b19c9b/32.png) [@hakuhal](https://forum.codewithmosh.com/u/hakuhal)\
**Post date:** [October 29, 2020, 10:36am UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/4 "2020-10-29T10:36:59Z")

</div>

I am glad it helped 😊

---

<div class="post-metadata">

**Author:** ![kukabshakiL125](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@kukabshakiL125](https://forum.codewithmosh.com/u/kukabshakiL125)\
**Post date:** [November 23, 2020, 8:47pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/5 "2020-11-23T20:47:00Z")

</div>

help me i am facing unpredictable error  
Setting vidly\_db and restarting ⬢ peaceful-cove-18303… done, v20  
vidly\_db: mongodb+srv://kukab:kokabsaqib40@vidly.gtszv.mongodb.net/vidly?retryWrites=true  
‘w’ is not recognized as an internal or external command,  
operable program or batch file.  
when I do heroku open

getting this error  
2020-11-23T20:32:38.091832+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" [host=peaceful-cove-18303.herokuapp.com](http://host=peaceful-cove-18303.herokuapp.com) request\_id=4954b87a-b9c1-4ce3-a330-36255bb8256a fwd=“175.107.225.94” dyno=web.1 connect=5000ms service= status=503 bytes= protocol=https

---

<div class="post-metadata">

**Author:** ![hakuhal](https://avatars.discourse-cdn.com/v4/letter/h/b19c9b/32.png) [@hakuhal](https://forum.codewithmosh.com/u/hakuhal)\
**Post date:** [December 4, 2020, 12:24pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/6 "2020-12-04T12:24:27Z")

</div>

do not use the “mongodb+srv://”, use the “mongodb://” options.

---

<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 3, 2021, 4:59am UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/7 "2021-01-03T04:59:52Z")

</div>

Hey, Thanks for your answer.

It helped me solve Unauthorized error. However, after following the steps I got this error.

‘MongoError: seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name’

Help would be appreciated.

My connection uri: mongodb://vidlyuser:@vidlydb-shard-00-00.wft4x.mongodb.net:27017,[vidlydb-shard-00-01.wft4x.mongodb.net:27017](http://vidlydb-shard-00-01.wft4x.mongodb.net:27017),[vidlydb-shard-00-02.wft4x.mongodb.net:27017/](http://vidlydb-shard-00-02.wft4x.mongodb.net:27017/)?ssl=true&replicaSet=atlas-13gtrm-shard-0&authSource=admin&retryWrites=true&w=majority

---

<div class="post-metadata">

**Author:** ![Ari87](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Ari87](https://forum.codewithmosh.com/u/Ari87)\
**Post date:** [January 5, 2021, 12:22am UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/8 "2021-01-05T00:22:02Z")

</div>

@sampreeth : I got the same error message. For me, using the Heroku CLI was removing characters after any ampersand claiming it is some command. Putting it in double quotes worked for small strings, but not large ones?!

ANYWAY, I used the Heroku dashboard ([https://dashboard.heroku.com/apps/](https://dashboard.heroku.com/apps/) --\> “Settings” button --\> “Reveal Config Vars” button) to put the mongodb (the 2.2.12 connect version) string in for the “vidly\_db” key with the appropriate changes (like password and database name).

I hope this fixes it for you.

---

<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, 12:52am UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/9 "2021-01-05T00:52:44Z")

</div>

How about authSource should I change that from admin to dbname?

---

<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, 1:18am UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/10 "2021-01-05T01:18:40Z")

</div>

@Ari87 I tried changing as mention.  
Now I’m getting.  
MongoError: Authentication failed. at NessageStream.messageHandler

However, my dbname is correct, password is the user password.

I’m stuck with this issue from 2 days. If you can help it would be really great.  
Thanks in advance.

---

<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.

---

<div class="post-metadata">

**Author:** ![faustologic](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/faustologic/32/578_2.png) [@faustologic](https://forum.codewithmosh.com/u/faustologic)\
**Post date:** [January 9, 2021, 4:47pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/12 "2021-01-09T16:47:42Z")

</div>

thank you man!! the first time I put Heroku open it take me to the server with no errors, then I try again and send me again application error why is that? Also, do I need to connect with that url the mongoDB desktop app?

---

<div class="post-metadata">

**Author:** ![SreejaP](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@SreejaP](https://forum.codewithmosh.com/u/SreejaP)\
**Post date:** [January 9, 2021, 8:30pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/15 "2021-01-09T20:30:35Z")

</div>

Thank you @sampreeth your solution helped

---

<div class="post-metadata">

**Author:** ![Shezad](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@Shezad](https://forum.codewithmosh.com/u/Shezad)\
**Post date:** [January 27, 2021, 2:13pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/16 "2021-01-27T14:13:42Z")

</div>

> [@SreejaP](#):
>
> @sampreeth

Thanks @sampreeth your solution saved me from hours of heartache

---

<div class="post-metadata">

**Author:** ![Justly](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/justly/32/5800_2.png) [@Justly](https://forum.codewithmosh.com/u/Justly)\
**Post date:** [February 4, 2021, 2:23pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/17 "2021-02-04T14:23:57Z")

</div>

Hi sorry to disturb you but can you help solve this axios error  
eperm: saying operation not permitted, read.  
Please i will be very much grateful thanks.  
Thanks

---

<div class="post-metadata">

**Author:** ![raj](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@raj](https://forum.codewithmosh.com/u/raj)\
**Post date:** [February 14, 2021, 6:25pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/18 "2021-02-14T18:25:21Z")

</div>

great @sampreeth brother for this tips work to me.i was struggle past 3 days but this time resolve this error.again thanks in advance. 🙂

---

<div class="post-metadata">

**Author:** ![oriya](https://avatars.discourse-cdn.com/v4/letter/o/2bfe46/32.png) [@oriya](https://forum.codewithmosh.com/u/oriya)\
**Post date:** [February 15, 2021, 2:09pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/19 "2021-02-15T14:09:53Z")

</div>

Thank You!  
it is helpfull!!

---

<div class="post-metadata">

**Author:** ![Pwnage5](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@Pwnage5](https://forum.codewithmosh.com/u/Pwnage5)\
**Post date:** [March 1, 2021, 9:53pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/20 "2021-03-01T21:53:00Z")

</div>

Thank you! 🙂 you are great

---

<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:** [March 4, 2021, 10:45am UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/21 "2021-03-04T10:45:35Z")

</div>

Hello Justly,  
sorry for the late reply, I hope your error has been resolved.

---

<div class="post-metadata">

**Author:** ![lesliefreeman](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/lesliefreeman/32/1081_2.png) [@lesliefreeman](https://forum.codewithmosh.com/u/lesliefreeman)\
**Post date:** [March 6, 2021, 8:36pm UTC](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297/22 "2021-03-06T20:36:32Z")

</div>

Thanks, guys for this helpful discussion for many of us, I appreciate that! [👍](https://www.buyessayscheap.com/homeworks.html)

[Next page](https://forum.codewithmosh.com/t/heroku-mongodb-deployment-error-react-course/297.md?page=2)
