Hello Team , I have recently installed growthbook ...
# ask-questions
i
Hello Team , I have recently installed growthbook on AKS cluster , when i am trying to access growthbook getting below error in pod.
Copy code
yarn run v1.22.19
$ wsrun -p 'back-end' -p 'front-end' --no-prefix -c start
$ node dist/server.js
$ next start
ready - started server on 0.0.0.0:3000, url: <http://localhost:3000>
/usr/local/src/app/packages/back-end/dist/util/secrets.js:55
    throw new Error("Cannot use JWT_SECRET=dev in production. Please set to a long random string.");
    ^

Error: Cannot use JWT_SECRET=dev in production. Please set to a long random string.
    at Object.<anonymous> (/usr/local/src/app/packages/back-end/dist/util/secrets.js:55:11)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Module.require (node:internal/modules/cjs/loader:1100:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/usr/local/src/app/packages/back-end/dist/init/config.js:11:19)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
`yarn start` failed with exit code 1
b
Hey Kuldeep - You need to set the JWT_SECRET environment variable to a long random string to use the API in production. Without that, an attacker could easily gain access to the system.
i
Thankyou , I habe set this env and now getting this error
Copy code
yarn run v1.22.19
$ wsrun -p 'back-end' -p 'front-end' --no-prefix -c start
$ next start
$ node dist/server.js
ready - started server on 0.0.0.0:3000, url: <http://localhost:3000>
{"level":30,"time":1698157639746,"pid":65,"hostname":"growthbook-7cf6cd6d94-v6vkk","msg":"No config.yml file. Using MongoDB instead to store data sources, metrics, and dimensions."}
(node:65) [MONGOOSE] DeprecationWarning: Mongoose: the `strictQuery` option will be switched back to `false` by default in Mongoose 7. Use `mongoose.set('strictQuery', false);` if you want to prepare for this change. Or use `mongoose.set('strictQuery', true);` to suppress this warning.
(Use `node --trace-deprecation ...` to show where the warning was created)
{"level":30,"time":1698157643730,"pid":65,"hostname":"growthbook-7cf6cd6d94-v6vkk","msg":"Back-end is running at <http://localhost:3100> in development mode. Press CTRL-C to stop"}
{"level":40,"time":1698157673727,"pid":65,"hostname":"growthbook-7cf6cd6d94-v6vkk","err":{"type":"MongooseServerSelectionError","message":"connect ECONNREFUSED 10.0.218.213:27017","stack":"MongooseServerSelectionError: connect ECONNREFUSED 10.0.218.213:27017\n    at NativeConnection.Connection.openUri (/usr/local/src/app/node_modules/mongoose/lib/connection.js:825:32)\n    at /usr/local/src/app/node_modules/mongoose/lib/index.js:414:10\n    at /usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5\n    at Promise._execute (/usr/local/src/app/node_modules/bluebird/js/release/debuggability.js:384:9)\n    at Promise._resolveFromExecutor (/usr/local/src/app/node_modules/bluebird/js/release/promise.js:518:18)\n    at new Promise (/usr/local/src/app/node_modules/bluebird/js/release/promise.js:103:10)\n    at promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)\n    at Mongoose._promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/index.js:1288:10)\n    at Mongoose.connect (/usr/local/src/app/node_modules/mongoose/lib/index.js:413:20)\n    at /usr/local/src/app/packages/back-end/dist/init/mongo.js:34:34\n    at Generator.next (<anonymous>)\n    at /usr/local/src/app/packages/back-end/dist/init/mongo.js:8:71\n    at new Promise (<anonymous>)\n    at __awaiter (/usr/local/src/app/packages/back-end/dist/init/mongo.js:4:12)\n    at exports.default (/usr/local/src/app/packages/back-end/dist/init/mongo.js:21:25)\n    at /usr/local/src/app/packages/back-end/dist/init/index.js:25:43","reason":{"type":"Unknown","servers":{},"stale":false,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"setName":null,"maxElectionId":null,"maxSetVersion":null,"commonWireVersion":0,"logicalSessionTimeoutMinutes":null}},"msg":"Failed to connect to MongoDB. Retrying with field remapping for mongodb v3 to v4"}
{"level":50,"time":1698157703735,"pid":65,"hostname":"growthbook-7cf6cd6d94-v6vkk","err":{"type":"MongooseServerSelectionError","message":"connect ECONNREFUSED 10.0.218.213:27017","stack":"MongooseServerSelectionError: connect ECONNREFUSED 10.0.218.213:27017\n    at NativeConnection.Connection.openUri (/usr/local/src/app/node_modules/mongoose/lib/connection.js:825:32)\n    at /usr/local/src/app/node_modules/mongoose/lib/index.js:414:10\n    at /usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5\n    at Promise._execute (/usr/local/src/app/node_modules/bluebird/js/release/debuggability.js:384:9)\n    at Promise._resolveFromExecutor (/usr/local/src/app/node_modules/bluebird/js/release/promise.js:518:18)\n    at new Promise (/usr/local/src/app/node_modules/bluebird/js/release/promise.js:103:10)\n    at promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)\n    at Mongoose._promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/index.js:1288:10)\n    at Mongoose.connect (/usr/local/src/app/node_modules/mongoose/lib/index.js:413:20)\n    at /usr/local/src/app/packages/back-end/dist/init/mongo.js:50:38\n    at Generator.throw (<anonymous>)\n    at rejected (/usr/local/src/app/packages/back-end/dist/init/mongo.js:6:65)","reason":{"type":"Unknown","servers":{},"stale":false,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"setName":null,"maxElectionId":null,"maxSetVersion":null,"commonWireVersion":0,"logicalSessionTimeoutMinutes":null}},"msg":"Failed to connect to MongoDB after retrying"}
{"level":50,"time":1698157703736,"pid":65,"hostname":"growthbook-7cf6cd6d94-v6vkk","err":{"type":"Error","message":"MongoDB connection error.","stack":"Error: MongoDB connection error.\n    at /usr/local/src/app/packages/back-end/dist/init/mongo.js:54:19\n    at Generator.throw (<anonymous>)\n    at rejected (/usr/local/src/app/packages/back-end/dist/init/mongo.js:6:65)"},"msg":"Failed to initialize application"}
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
`yarn start` failed with exit code 1
i have already set and configure MONGODB URI , and mongo db is also running
b
It looks like it's not able to connect to MongoDB. Are you running Mongo in Kubernetes? It seems like the Mongo isn't accessible from your AKS cluster.
i
yeah i am running mongodb as a pod in same namespace
Copy code
kubectl get pod | grep -i mongo
mongodb-pod                                              1/1     Running   0          3d22h
kubectl get pod | grep -i growthbook
growthbook-7cf6cd6d94-v6vkk                              1/1     Running   0          76m
Mongo URI is also updated in env
Copy code
env:
        - name: MONGODB_URI
          value: <mongodb://root:password@mongo:27017/growthbook?authSource=admin>
        - name: API_HOST
          value: <http://service.dev.caret.legal>
        - name: APP_ORIGIN
          value: <http://growthbook.dev.caret.legal>
        - name: JWT_SECRET
          value: '1234567890'