bradtraversy / mern_shopping_list

Shopping List built with MERN and Redux
605 stars 436 forks source link

HEROKU ERROR --- Error [MongooseError]: The `uri` parameter to `openUri()` must be a string, got "undefined". #33

Open JoePappano opened 4 years ago

JoePappano commented 4 years ago

Getting this error on the Heroku logs:

Error [MongooseError]: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string. 2020-01-26T01:33:51.682367+00:00 app[web.1]: at new MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:10:11) 2020-01-26T01:33:51.682370+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:543:11) 2020-01-26T01:33:51.682373+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:332:15) 2020-01-26T01:33:51.682379+00:00 app[web.1]: at Object. (/app/server.js:19:6) 2020-01-26T01:33:51.682381+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:955:30) 2020-01-26T01:33:51.682383+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10) 2020-01-26T01:33:51.682385+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:811:32) 2020-01-26T01:33:51.682387+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:723:14) 2020-01-26T01:33:51.682389+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) 2020-01-26T01:33:51.682390+00:00 app[web.1]: at internal/main/run_main_module.js:17:11 { 2020-01-26T01:33:51.682393+00:00 app[web.1]: message: 'The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string.', 2020-01-26T01:33:51.682396+00:00 app[web.1]: name: 'MongooseError' 2020-01-26T01:33:51.682398+00:00 app[web.1]: } 2020-01-26T01:33:51.696226+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2020-01-26T01:33:51.696758+00:00 app[web.1]: npm ERR! errno 1 2020-01-26T01:33:51.698891+00:00 app[web.1]: npm ERR! reworkfinder@1.0.0 start: node server.js 2020-01-26T01:33:51.699327+00:00 app[web.1]: npm ERR! Exit status 1 2020-01-26T01:33:51.699717+00:00 app[web.1]: npm ERR! 2020-01-26T01:33:51.700059+00:00 app[web.1]: npm ERR! Failed at the reworkfinder@1.0.0 start script. 2020-01-26T01:33:51.700404+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2020-01-26T01:33:51.709040+00:00 app[web.1]: 2020-01-26T01:33:51.709588+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2020-01-26T01:33:51.709906+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-01-26T01_33_51_701Z-debug.log

Anyone have this issue?

stoofn-hooml commented 4 years ago

You need to set an environment variable for your mongoDB connection string, as that was stored locally on your machine and is not in the heroku server. This can be done either in the Heroku site under the settings tab of your application, or through the CLI with a command like heroku config:set mongoURI=database_uri_here. Here is a link to a similar issue: https://stackoverflow.com/questions/40119964/how-to-set-environment-variables-on-heroku-for-nodes-app-and-connect-to-the-post

Usama-Nazir commented 1 day ago

I'm getting this error to connect with my MongoDB database Error Connecting to Database MongooseError: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string.