Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
DAN\node_modules\mongoose\lib\connection.js:695
    throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
          ^

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.
    at NativeConnection.Connection.openUri (C:\Users\bhide\Desktop\APPOINTMENT BOOKING FOR SEVASADAN\node_modules\mongoose\lib\connection.js:695:11)
    at C:\Users\bhide\Desktop\APPOINTMENT BOOKING FOR SEVASADAN\node_modules\mongoose\lib\index.js:414:10
    at C:\Users\bhide\Desktop\APPOINTMENT BOOKING FOR SEVASADAN\node_modules\mongoose\lib\helpers\promiseOrCallback.js:41:5
    at new Promise (<anonymous>)
    at promiseOrCallback (C:\Users\bhide\Desktop\APPOINTMENT BOOKING FOR SEVASADAN\node_modules\mongoose\lib\helpers\promiseOrCallback.js:40:10)
    at Mongoose._promiseOrCallback (C:\Users\bhide\Desktop\APPOINTMENT BOOKING FOR SEVASADAN\node_modules\mongoose\lib\index.js:1288:10)
    at Mongoose.connect (C:\Users\bhide\Desktop\APPOINTMENT BOOKING FOR SEVASADAN\node_modules\mongoose\lib\index.js:413:20)
    at Object.<anonymous> (C:\Users\bhide\Desktop\APPOINTMENT BOOKING FOR SEVASADAN\config\dbconfig.js:3:10)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
[nodemon] app crashed - waiting for file changes before starting...


What I have tried:

My .env file is in the root folder.
Posted
Updated 23-Feb-23 4:47am

1 solution

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

The error message is telling you that something is wrong with the parameter you are using to connect to mongoose. So check your code to see why.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900