Can anyone help me solve this issue: `uri` parameter to `openUri()` must be a string, got "undefined"

I’m trying to host my backend Server folder but I’m getting this error and have no clue where the issue is. I looked on stackoverflow, but it’s no.

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.

Hey there

From the error message it seems that the variable you are using doesn’t have any value or does not exist. My first guess is that you’re doing something like

mongoose.connect(process.env.MONGODB_URI

but that env variable is not defined in your render settings. That’s just a guess.

How are you connecting to Mongo? Can you share a code snippet?

Hey,

My guess is that you’re calling a process.env variable in your code but haven’t added the value as an environment variable in your Render service: https://render.com/docs/configure-environment-variables

Jérémy, Render Support