Saloni Patil
Saloni Patil

Reputation: 1

MongooseError: T he connection string is not valid

I have issue via connecting with database to my backend in mongodb compass database

I want to know what exactly the issue is there

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 Connection.openUri (D:\Microservices\Grocery_Online_Shopping_App\online_shopping_monolithic\node_modules\mongoose\lib\connection.js:694:11)
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 Connection.openUri (D:\Microservices\Grocery_Online_Shopping_App\online_shopping_monolithic\node_modules\mongoose\lib\connection.js:694:11)
connect()` or `mongoose.createConnection()` is a string.
    

Upvotes: -1

Views: 25

Answers (1)

Deepesh Jain
Deepesh Jain

Reputation: 41

Pass the connection string to mongoose.connect(CONNECTION_STRING).

It is currently undefined, start by logging the value to the console.

If you're retrieving the connection string from environment variables, it's likely that the environment variables are not being loaded correctly.

Upvotes: 0

Related Questions