Heroku mongodb deployment error React course

How in the world do I solve this?


this is a different project not vidly

@sampreeth Thank you so much for your detailed solution.

1 Like

@sampreeth Thank you very much I’ve been stuck with connecting MongoDB Atlas and Heroku for half a day your answer saved me.

1 Like

I can’t even thank you enough, because that problem already took me 2 days until I found your solution.
again thank you for sharing the solution

1 Like

thanks a lot, it really hepled

As of February 2021, there are more issues coming up as in attached, hope to get some quick help around.

2022-02-16T17:56:40.728432+00:00 app[web.1]: stack: [
2022-02-16T17:56:40.728433+00:00 app[web.1]: 'Error: The provided mongoose instance is invalid',
2022-02-16T17:56:40.728433+00:00 app[web.1]: '    at Object.init (/app/node_modules/fawn/lib/fawn.js:30:15)',
2022-02-16T17:56:40.728434+00:00 app[web.1]: '    at Object.<anonymous> (/app/routes/rentals.js:10:6)',
2022-02-16T17:56:40.728434+00:00 app[web.1]: '    at Module._compile (node:internal/modules/cjs/loader:1103:14)',
2022-02-16T17:56:40.728434+00:00 app[web.1]: '    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)',
2022-02-16T17:56:40.728434+00:00 app[web.1]: '    at Module.load (node:internal/modules/cjs/loader:981:32)',
2022-02-16T17:56:40.728435+00:00 app[web.1]: '    at Function.Module._load (node:internal/modules/cjs/loader:822:12)',
2022-02-16T17:56:40.728435+00:00 app[web.1]: '    at Module.require (node:internal/modules/cjs/loader:1005:19)',
2022-02-16T17:56:40.728435+00:00 app[web.1]: '    at require (node:internal/modules/cjs/helpers:102:18)',
2022-02-16T17:56:40.728436+00:00 app[web.1]: '    at Object.<anonymous> (/app/startup/routes.js:5:17)',
2022-02-16T17:56:40.728436+00:00 app[web.1]: '    at Module._compile (node:internal/modules/cjs/loader:1103:14)',
2022-02-16T17:56:40.728436+00:00 app[web.1]: '    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)',
2022-02-16T17:56:40.728437+00:00 app[web.1]: '    at Module.load (node:internal/modules/cjs/loader:981:32)',
2022-02-16T17:56:40.728437+00:00 app[web.1]: '    at Function.Module._load (node:internal/modules/cjs/loader:822:12)',
2022-02-16T17:56:40.728438+00:00 app[web.1]: '    at Module.require (node:internal/modules/cjs/loader:1005:19)',
2022-02-16T17:56:40.728438+00:00 app[web.1]: '    at require (node:internal/modules/cjs/helpers:102:18)',
2022-02-16T17:56:40.728438+00:00 app[web.1]: '    at Object.<anonymous> (/app/index.js:8:1)'
2022-02-16T17:56:40.728438+00:00 app[web.1]: ]
2022-02-16T17:56:40.728439+00:00 app[web.1]: }
2022-02-16T17:56:40.737386+00:00 app[web.1]: (node:22) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
2022-02-16T17:56:40.737388+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2022-02-16T17:56:40.980590+00:00 heroku[web.1]: Process exited with status 1
2022-02-16T17:56:41.062608+00:00 heroku[web.1]: State changed from starting to crashed
2022-02-16T17:56:42.355246+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vidly-api-arifmd.herokuapp.com request_id=2fa872f2-4e20-4e47-86c8-c0a0477f9e03 fwd="103.79.169.11" dyno= connect= service= status=503 bytes= protocol=https
2022-02-16T17:56:42.880868+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vidly-api-arifmd.herokuapp.com request_id=7d30fc63-d801-4303-b6da-8ef1eff36a9a fwd="103.79.169.11" dyno= connect= service= status=503 bytes= protocol=https
2022-02-16T17:56:48.325112+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/api/genres" host=vidly-api-arifmd.herokuapp.com request_id=fe215f4f-567a-4741-9003-80601a4aa421 fwd="103.79.169.11" dyno= connect= service= status=503 bytes= protocol=https
2022-02-16T17:56:48.974597+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/api/genres" host=vidly-api-arifmd.herokuapp.com request_id=9f027226-fa40-4a39-a532-fd321de29d4c fwd="103.79.169.11" dyno= connect= service= status=503 bytes= protocol=https
2022-02-16T17:56:49.419548+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vidly-api-arifmd.herokuapp.com request_id=def8ec17-15d0-4e50-9454-be25e0a5231a fwd="103.79.169.11" dyno= connect= service= status=503 bytes= protocol=https

Just to test the issue further, I have reverted the mongoose version to `5.11.10 and getting another (I feel like) easier issue though followed all the steps about IP whitelisting but didn’t have any luck, something going wrong from mongodb side.

2022-02-17T05:19:10.997916+00:00 app[web.1]: stack: [
2022-02-17T05:19:10.997916+00:00 app[web.1]: "MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/",
2022-02-17T05:19:10.997917+00:00 app[web.1]: '    at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:832:32)',
2022-02-17T05:19:10.997917+00:00 app[web.1]: '    at /app/node_modules/mongoose/lib/index.js:345:10',
2022-02-17T05:19:10.997917+00:00 app[web.1]: '    at /app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:5',
2022-02-17T05:19:10.997918+00:00 app[web.1]: '    at Promise._execute (/app/node_modules/bluebird/js/release/debuggability.js:300:9)',
2022-02-17T05:19:10.997918+00:00 app[web.1]: '    at Promise._resolveFromExecutor (/app/node_modules/bluebird/js/release/promise.js:483:18)',
2022-02-17T05:19:10.997918+00:00 app[web.1]: '    at new Promise (/app/node_modules/bluebird/js/release/promise.js:79:10)',
2022-02-17T05:19:10.997918+00:00 app[web.1]: '    at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:30:10)',
2022-02-17T05:19:10.997919+00:00 app[web.1]: '    at Mongoose._promiseOrCallback (/app/node_modules/mongoose/lib/index.js:1135:10)',
2022-02-17T05:19:10.997919+00:00 app[web.1]: '    at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:344:20)',
2022-02-17T05:19:10.997919+00:00 app[web.1]: '    at module.exports (/app/startup/db.js:8:6)',
2022-02-17T05:19:10.997919+00:00 app[web.1]: '    at Object.<anonymous> (/app/index.js:9:24)',
2022-02-17T05:19:10.997919+00:00 app[web.1]: '    at Module._compile (node:internal/modules/cjs/loader:1103:14)',
2022-02-17T05:19:10.997920+00:00 app[web.1]: '    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)',
2022-02-17T05:19:10.997920+00:00 app[web.1]: '    at Module.load (node:internal/modules/cjs/loader:981:32)',
2022-02-17T05:19:10.997920+00:00 app[web.1]: '    at Function.Module._load (node:internal/modules/cjs/loader:822:12)',
2022-02-17T05:19:10.997920+00:00 app[web.1]: '    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)',
2022-02-17T05:19:10.997921+00:00 app[web.1]: '    at node:internal/main/run_main_module:17:47'
2022-02-17T05:19:10.997921+00:00 app[web.1]: ]

Copying connection string for node driver version 2.2.12 works for me, earlier I was trying to using the latest, hope it helps someone :slight_smile:

Hi all,

I have followed the steps outlined by @sampreeth as I was encountering a similar ‘circular dependancy’ error as encountered by @arifmd , but it hasnt solved the problem. My heroku logs are shown below. Any help would be much appreciated.

 ›   Warning: heroku update available from 7.59.2 to 7.59.3.
Maximillans-MacBook-Pro-2:vidly-api-node ZULU$ heroku logs --tail
 ›   Warning: heroku update available from 7.59.2 to 7.59.3.
2022-03-11T12:28:34.040341+00:00 app[web.1]: method: '_compile',
2022-03-11T12:28:34.040341+00:00 app[web.1]: native: false
2022-03-11T12:28:34.040342+00:00 app[web.1]: },
2022-03-11T12:28:34.040342+00:00 app[web.1]: {
2022-03-11T12:28:34.040342+00:00 app[web.1]: column: 10,
2022-03-11T12:28:34.040348+00:00 app[web.1]: file: 'node:internal/modules/cjs/loader',
2022-03-11T12:28:34.040349+00:00 app[web.1]: function: 'Module._extensions..js',
2022-03-11T12:28:34.040349+00:00 app[web.1]: line: 1155,
2022-03-11T12:28:34.040349+00:00 app[web.1]: method: '.js',
2022-03-11T12:28:34.040349+00:00 app[web.1]: native: false
2022-03-11T12:28:34.040350+00:00 app[web.1]: },
2022-03-11T12:28:34.040350+00:00 app[web.1]: {
2022-03-11T12:28:34.040350+00:00 app[web.1]: column: 32,
2022-03-11T12:28:34.040350+00:00 app[web.1]: file: 'node:internal/modules/cjs/loader',
2022-03-11T12:28:34.040351+00:00 app[web.1]: function: 'Module.load',
2022-03-11T12:28:34.040351+00:00 app[web.1]: line: 981,
2022-03-11T12:28:34.040351+00:00 app[web.1]: method: 'load',
2022-03-11T12:28:34.040351+00:00 app[web.1]: native: false
2022-03-11T12:28:34.040352+00:00 app[web.1]: },
2022-03-11T12:28:34.040352+00:00 app[web.1]: {
2022-03-11T12:28:34.040352+00:00 app[web.1]: column: 12,
2022-03-11T12:28:34.040352+00:00 app[web.1]: file: 'node:internal/modules/cjs/loader',
2022-03-11T12:28:34.040353+00:00 app[web.1]: function: 'Module._load',
2022-03-11T12:28:34.040353+00:00 app[web.1]: line: 822,
2022-03-11T12:28:34.040353+00:00 app[web.1]: method: '_load',
2022-03-11T12:28:34.040353+00:00 app[web.1]: native: false
2022-03-11T12:28:34.040354+00:00 app[web.1]: },
2022-03-11T12:28:34.040354+00:00 app[web.1]: {
2022-03-11T12:28:34.040354+00:00 app[web.1]: column: 19,
2022-03-11T12:28:34.040354+00:00 app[web.1]: file: 'node:internal/modules/cjs/loader',
2022-03-11T12:28:34.040355+00:00 app[web.1]: function: 'Module.require',
2022-03-11T12:28:34.040355+00:00 app[web.1]: line: 1005,
2022-03-11T12:28:34.040355+00:00 app[web.1]: method: 'require',
2022-03-11T12:28:34.040356+00:00 app[web.1]: native: false
2022-03-11T12:28:34.040356+00:00 app[web.1]: },
2022-03-11T12:28:34.040356+00:00 app[web.1]: {
2022-03-11T12:28:34.040356+00:00 app[web.1]: column: 18,
2022-03-11T12:28:34.040357+00:00 app[web.1]: file: 'node:internal/modules/cjs/helpers',
2022-03-11T12:28:34.040357+00:00 app[web.1]: function: 'require',
2022-03-11T12:28:34.040357+00:00 app[web.1]: line: 102,
2022-03-11T12:28:34.040358+00:00 app[web.1]: method: null,
2022-03-11T12:28:34.040365+00:00 app[web.1]: native: false
2022-03-11T12:28:34.040365+00:00 app[web.1]: },
2022-03-11T12:28:34.040365+00:00 app[web.1]: {
2022-03-11T12:28:34.040365+00:00 app[web.1]: column: 15,
2022-03-11T12:28:34.040366+00:00 app[web.1]: file: '/app/startup/routes.js',
2022-03-11T12:28:34.040366+00:00 app[web.1]: function: null,
2022-03-11T12:28:34.040366+00:00 app[web.1]: line: 6,
2022-03-11T12:28:34.040367+00:00 app[web.1]: method: null,
2022-03-11T12:28:34.040367+00:00 app[web.1]: native: false
2022-03-11T12:28:34.040367+00:00 app[web.1]: },
2022-03-11T12:28:34.040367+00:00 app[web.1]: {
2022-03-11T12:28:34.040368+00:00 app[web.1]: column: 14,
2022-03-11T12:28:34.040368+00:00 app[web.1]: file: 'node:internal/modules/cjs/loader',
2022-03-11T12:28:34.040368+00:00 app[web.1]: function: 'Module._compile',
2022-03-11T12:28:34.040368+00:00 app[web.1]: line: 1103,
2022-03-11T12:28:34.040369+00:00 app[web.1]: method: '_compile',
2022-03-11T12:28:34.040369+00:00 app[web.1]: native: false
2022-03-11T12:28:34.040369+00:00 app[web.1]: },
2022-03-11T12:28:34.040369+00:00 app[web.1]: {
2022-03-11T12:28:34.040370+00:00 app[web.1]: column: 10,
2022-03-11T12:28:34.040370+00:00 app[web.1]: file: 'node:internal/modules/cjs/loader',
2022-03-11T12:28:34.040370+00:00 app[web.1]: function: 'Module._extensions..js',
2022-03-11T12:28:34.040371+00:00 app[web.1]: line: 1155,
2022-03-11T12:28:34.040371+00:00 app[web.1]: method: '.js',
2022-03-11T12:28:34.040371+00:00 app[web.1]: native: false
2022-03-11T12:28:34.040371+00:00 app[web.1]: }
2022-03-11T12:28:34.040372+00:00 app[web.1]: ],
2022-03-11T12:28:34.040372+00:00 app[web.1]: stack: [
2022-03-11T12:28:34.040372+00:00 app[web.1]: 'Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header',
2022-03-11T12:28:34.040373+00:00 app[web.1]: '    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1185:18)',
2022-03-11T12:28:34.040374+00:00 app[web.1]: '    at Module.load (node:internal/modules/cjs/loader:981:32)',
2022-03-11T12:28:34.040374+00:00 app[web.1]: '    at Function.Module._load (node:internal/modules/cjs/loader:822:12)',
2022-03-11T12:28:34.040374+00:00 app[web.1]: '    at Module.require (node:internal/modules/cjs/loader:1005:19)',
2022-03-11T12:28:34.040374+00:00 app[web.1]: '    at require (node:internal/modules/cjs/helpers:102:18)',
2022-03-11T12:28:34.040375+00:00 app[web.1]: '    at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)',
2022-03-11T12:28:34.040375+00:00 app[web.1]: '    at Module._compile (node:internal/modules/cjs/loader:1103:14)',
2022-03-11T12:28:34.040375+00:00 app[web.1]: '    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)',
2022-03-11T12:28:34.040376+00:00 app[web.1]: '    at Module.load (node:internal/modules/cjs/loader:981:32)',
2022-03-11T12:28:34.040376+00:00 app[web.1]: '    at Function.Module._load (node:internal/modules/cjs/loader:822:12)',
2022-03-11T12:28:34.040376+00:00 app[web.1]: '    at Module.require (node:internal/modules/cjs/loader:1005:19)',
2022-03-11T12:28:34.040376+00:00 app[web.1]: '    at require (node:internal/modules/cjs/helpers:102:18)',
2022-03-11T12:28:34.040377+00:00 app[web.1]: '    at Object.<anonymous> (/app/routes/users.js:2:16)',
2022-03-11T12:28:34.040377+00:00 app[web.1]: '    at Module._compile (node:internal/modules/cjs/loader:1103:14)',
2022-03-11T12:28:34.040377+00:00 app[web.1]: '    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)',
2022-03-11T12:28:34.040378+00:00 app[web.1]: '    at Module.load (node:internal/modules/cjs/loader:981:32)',
2022-03-11T12:28:34.040378+00:00 app[web.1]: '    at Function.Module._load (node:internal/modules/cjs/loader:822:12)',
2022-03-11T12:28:34.040378+00:00 app[web.1]: '    at Module.require (node:internal/modules/cjs/loader:1005:19)',
2022-03-11T12:28:34.040378+00:00 app[web.1]: '    at require (node:internal/modules/cjs/helpers:102:18)',
2022-03-11T12:28:34.040378+00:00 app[web.1]: '    at Object.<anonymous> (/app/startup/routes.js:6:15)',
2022-03-11T12:28:34.040379+00:00 app[web.1]: '    at Module._compile (node:internal/modules/cjs/loader:1103:14)',
2022-03-11T12:28:34.040379+00:00 app[web.1]: '    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)'
2022-03-11T12:28:34.040379+00:00 app[web.1]: ]
2022-03-11T12:28:34.040379+00:00 app[web.1]: }
2022-03-11T12:28:34.047770+00:00 app[web.1]: (node:22) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
2022-03-11T12:28:34.047771+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2022-03-11T12:28:34.189951+00:00 heroku[web.1]: Process exited with status 1
2022-03-11T12:28:34.246062+00:00 heroku[web.1]: State changed from starting to crashed
2022-03-11T12:29:04.225185+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-spire-07708.herokuapp.com request_id=b14ee7b7-882f-4a3e-96ae-a9fa149f9e0a fwd="86.179.98.215" dyno= connect= service= status=503 bytes= protocol=https
2022-03-11T12:29:05.307903+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-spire-07708.herokuapp.com request_id=9492fe81-cfa4-43d9-90b1-43538b76a900 fwd="86.179.98.215" dyno= connect= service= status=503 bytes= protocol=https

Your solution did it for me, thank you very much!

I just want to add one thing: When you copy the cluster connection string in Atlas, it may not have a space for the database name . What worked for me was placing the database name right after the port number located before the SSL (mongodb.net:27017/dbname?ssl=true…) as shown in @sampreeth 's example. It was confusing that the cluster connection string did not have a dbname space. Thanks, @sampreeth Your instructions helped me update my Vidly movie app, and now it is running fine.
Also, if your Vidly movie app is throwing a CORS error, then it very well could be that you have to make the updates suggested by @sampreeth including changing your connection string.
Best! Brian

Sampreeth, thank you for sharing the solution! It made my day today =) This solution is still working at the moment.

This is the error I get all the time. I have tried every solution that has been provided in this thread but I have had no success. It’s been a month now since I have been stuck here. I need help seriously.

 "MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://www.mongodb.com/docs/atlas/security-whitelist/",
2023-05-16T09:15:21.908461+00:00 app[web.1]: '    at Connection.openUri (/app/node_modules/mongoose/lib/connection.js:825:32)',
2023-05-16T09:15:21.908461+00:00 app[web.1]: '    at /app/node_modules/mongoose/lib/index.js:414:10',
2023-05-16T09:15:21.908461+00:00 app[web.1]: '    at /app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5',
2023-05-16T09:15:21.908461+00:00 app[web.1]: '    at new Promise (<anonymous>)',
2023-05-16T09:15:21.908461+00:00 app[web.1]: '    at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)',
2023-05-16T09:15:21.908462+00:00 app[web.1]: '    at Mongoose._promiseOrCallback (/app/node_modules/mongoose/lib/index.js:1288:10)',
2023-05-16T09:15:21.908462+00:00 app[web.1]: '    at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:413:20)',
2023-05-16T09:15:21.908462+00:00 app[web.1]: '    at module.exports (/app/startup/db.js:8:6)',
2023-05-16T09:15:21.908462+00:00 app[web.1]: '    at Object.<anonymous> (/app/index.js:9:24)',
2023-05-16T09:15:21.908462+00:00 app[web.1]: '    at Module._compile (node:internal/modules/cjs/loader:1254:14)',
2023-05-16T09:15:21.908462+00:00 app[web.1]: '    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)',
2023-05-16T09:15:21.908463+00:00 app[web.1]: '    at Module.load (node:internal/modules/cjs/loader:1117:32)',
2023-05-16T09:15:21.908463+00:00 app[web.1]: '    at Module._load (node:internal/modules/cjs/loader:958:12)',
2023-05-16T09:15:21.908463+00:00 app[web.1]: '    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)',
2023-05-16T09:15:21.908463+00:00 app[web.1]: '    at node:internal/main/run_main_module:23:47'
2023-05-16T09:15:21.908463+00:00 app[web.1]: ]
2023-05-16T09:15:21.908463+00:00 app[web.1]: }
2023-05-16T09:15:21.916291+00:00 app[web.1]: npm notice
2023-05-16T09:15:21.916358+00:00 app[web.1]: npm notice New minor version of npm available! 9.5.1 -> 9.6.6
2023-05-16T09:15:21.916558+00:00 app[web.1]: npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.6.6>
2023-05-16T09:15:21.916617+00:00 app[web.1]: npm notice Run `npm install -g npm@9.6.6` to update!
2023-05-16T09:15:21.916738+00:00 app[web.1]: npm notice
2023-05-16T09:15:22.050550+00:00 heroku[web.1]: Process exited with status 1
2023-05-16T09:15:22.088039+00:00 heroku[web.1]: State changed from up to crashed

Why is nobody trying to help me?

I have spent months now trying to deploy my React.