Hi, I'm trying to get Growthbook running on a loca...
# ask-questions
g
Hi, I'm trying to get Growthbook running on a local machine so we can test it. I had it working a couple weeks ago, but it no longer works. The error that I'm getting is on
growthbook-growthbook-1
with the error:
Copy code
Failed to connect to MongoDB. Retrying with field remapping for mongodb v3 to v4
Is this a known issue?
f
Are you using the included docker-compose file? Did you make any changes there?
g
No. I removed all my volumes in Docker, deleted the growthbook folder, and recloned. I always have this issue.
f
Hmm. Are there any docker errors for Mongo? I'm wondering if that container failed to start for some reason
g
Here is the file:
Copy code
version: "3"
services:
  mongo:
    image: "mongo:latest"
    environment:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=password

  growthbook:
    image: "growthbook/growthbook:latest"
    ports:
      - "3000:3000"
      - "3100:3100"
    depends_on:
      - mongo
    environment:
      - MONGODB_URI=<mongodb://root:password@mongo:27017/growthbook?authSource=admin>
      # Proxy settings
      - PROXY_ENABLED=1
      - PROXY_HOST_INTERNAL=<http://proxy:3300>
      - PROXY_HOST_PUBLIC=<http://localhost:3300>
      # Change this to something secure in production!
      - SECRET_API_KEY=dev
    volumes:
      - uploads:/usr/local/src/app/packages/back-end/uploads

  proxy:
    image: "growthbook/proxy:latest"
    ports:
      - "3300:3300"
    depends_on:
      - growthbook
    environment:
      - GROWTHBOOK_API_HOST=<http://growthbook:3100>
      # This must match the SECRET_API_KEY above
      - SECRET_API_KEY=dev

volumes:
  uploads:
When I
docker-compose up
, here is the last mongo long before I attempt to connect:
Copy code
growthbook-mongo-1       | {"t":{"$date":"2023-06-08T13:50:50.505+00:00"},"s":"I",  "c":"NETWORK",  "id":23016,   "ctx":"listener","msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}
Then I only receive logs on the
growthbook-growthbook-1
instance:
Copy code
"msg":"Failed to connect to MongoDB. Retrying with field remapping for mongodb v3 to v4"
then
Copy code
"msg":"Failed to connect to MongoDB after retrying"
Then a complaint about yarn
Copy code
growthbook-growthbook-1  |  | {"level":50,"time":1686232307732,"pid":64,"hostname":"eb3a8bf0f9fb","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"}
growthbook-growthbook-1  |  | info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
growthbook-growthbook-1  |  | error Command failed with exit code 1.
growthbook-growthbook-1  |  | `yarn start` failed with exit code 1
f
Can you see what Mongo version it's using? I can try to reproduce locally
I was unable to reproduce it locally using the latest Mongo image (6.0.6). Based on the log ordering, does it look like it might be a race condition? GrowthBook starts up and tries to connect before Mongo is fully initialized and ready for connections? I did notice an unrelated bug while testing with the proxy server. I have a PR up to fix that which I'll merge today after some more testing. https://github.com/growthbook/growthbook/pull/1346