10 months ago
I don't understand why I can't access to my enviroment variables in my project Nest js, got this:
[Nest] 27 - 07/03/2024, 2:50:39 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (8)...
[Nest] 27 - 07/03/2024, 2:50:42 PM ERROR [MongooseModule] Unable to connect to the database. Retrying (9)...
[Nest] 27 - 07/03/2024, 2:50:42 PM ERROR [ExceptionHandler] 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.
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.createClient (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:219:11)
at NativeConnection.openUri (/app/node_modules/mongoose/lib/connection.js:822:34)
at Mongoose.createConnection (/app/node_modules/mongoose/lib/mongoose.js:373:10)
at Function.createMongooseConnection (/app/node_modules/@nestjs/mongoose/dist/mongoose-core.module.js:114:37)
at /app/node_modules/@nestjs/mongoose/dist/mongoose-core.module.js:65:123
at Observable._subscribe (/app/node_modules/rxjs/src/internal/observable/defer.ts:55:15)
at Observable._trySubscribe (/app/node_modules/rxjs/src/internal/Observable.ts:244:19)
at /app/node_modules/rxjs/src/internal/Observable.ts:234:18
at Object.errorContext (/app/node_modules/rxjs/src/internal/util/errorContext.ts:29:5)
This is my repo:
https://github.com/ROR2022/servercornerstore
7 Replies
10 months ago
Are they defined at Railway or only in your .env file?
Yes they are...
10 months ago
Have a look at this basic implementation. Probably is the best way to share your variables inside your app in railway. https://github.com/allen-n/nestjs-generic
10 months ago
It would not be best to include variables in the repo, that is very insecure, please only ever use service variables.
Status changed to Solved railway[bot] • 10 months ago
10 months ago
do you use dotenv.config()?
ror2022
thanks, I've finally seen my error.
23 days ago
How did you solve it, I am having the same issue
Status changed to Open railway[bot] • 23 days ago