https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
j

jolly-chef-93830

02/14/2024, 11:28 AM
Hello everyone, I am getting error in self hosting part when I am sending config.yml file for mysql connection. 2024-02-14 165142 growthbook-1 | {"level":50,"time":1707909702995,"pid":58,"hostname":"c8e52db7dc35","err":{"type":"MongooseServerSelectionError","message":"connect ECONNREFUSED 127.0.0.1:27017","stack":"MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017\n at Connection.openUri (/usr/local/src/app/node_modules/mongoose/lib/connection.js82532)\n at /usr/local/src/app/node_modules/mongoose/lib/index.js41410\n at /usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js415\n at Promise._execute (/usr/local/src/app/node_modules/bluebird/js/release/debuggability.js3849)\n at Promise._resolveFromExecutor (/usr/local/src/app/node_modules/bluebird/js/release/promise.js51818)\n at new Promise (/usr/local/src/app/node_modules/bluebird/js/release/promise.js10310)\n at promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js4010)\n at Mongoose._promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/index.js128810)\n at Mongoose.connect (/usr/local/src/app/node_modules/mongoose/lib/index.js41320)\n at /usr/local/src/app/packages/back-end/dist/init/mongo.js5038\n at Generator.throw (<anonymous>)\n at rejected (/usr/local/src/app/packages/back-end/dist/init/mongo.js665)","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"} 2024-02-14 165142 growthbook-1 | {"level":50,"time":1707909702996,"pid":58,"hostname":"c8e52db7dc35","err":{"type":"Error","message":"MongoDB connection error.","stack":"Error: MongoDB connection error.\n at /usr/local/src/app/packages/back-end/dist/init/mongo.js5419\n at Generator.throw (<anonymous>)\n at rejected (/usr/local/src/app/packages/back-end/dist/init/mongo.js665)"},"msg":"Failed to initialize application"}
f

fresh-football-47124

02/15/2024, 5:50 AM
"MongoDB connection error"
can you check that you have Mongo or a DocumentDB running?
and then check the connection string
you can verify it works with Mongo Compass if you like
j

jolly-chef-93830

02/15/2024, 5:52 AM
version: "3" services: mysql: image: mysql:latest environment: - MYSQL_ROOT_PASSWORD=password volumes: - mysqldata:/var/lib/mysql growthbook: build: context: . dockerfile: Dockerfile ports: - "4000:3000" - "4100:3100" depends_on: - mysql environment: - MYSQL_HOST=mysql - MYSQL_PORT=3306 - MYSQL_DATABASE=growthbook - MYSQL_USER=root - MYSQL_PASSWORD=password - APP_ORIGIN=http://localhost:4000 - API_HOST=http://localhost:4100 - CACHE_ENGINE=redis - CACHE_CONNECTION_URL=redis://localhost:6379 - CACHE_STALE_TTL=5 - CACHE_EXPIRES_TTL=5 volumes: - uploads:/usr/local/src/app/packages/back-end/uploads volumes: uploads: mysqldata: but I am using mysql, why its trying to connect with mongo?
f

fresh-football-47124

02/15/2024, 5:53 AM
GrowthBook requires a nosql db to work for its own internal db
j

jolly-chef-93830

02/15/2024, 5:53 AM
mysql db is also running.
f

fresh-football-47124

02/15/2024, 5:54 AM
where you store your data is separate
looks like mongo is running- but sounds like you have to set the connection string
correctly
j

jolly-chef-93830

02/15/2024, 5:55 AM
# docker-compose.yml version: "3" services: mongo: image: "mongo:latest" environment: - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=password volumes: - mongodata:/data/db growthbook: # image: "growthbook/growthbook:latest" build: context: . dockerfile: Dockerfile ports: - "4000:3000" - "4100:3100" depends_on: - mongo environment: - MONGODB_URI=mongodb://root:password@mongo:27017/growthbook?authSource=admin - APP_ORIGIN=http://localhost:4000 - API_HOST=http://localhost:4100 - CACHE_ENGINE:"redis" - CACHE_CONNECTION_URL:"redis://localhost:6379" - CACHE_STALE_TTL:5 - CACHE_EXPIRES_TTL:5 volumes: - uploads:/usr/local/src/app/packages/back-end/uploads volumes: uploads: mongodata: like this?
f

fresh-football-47124

02/15/2024, 5:56 AM
I think so
you can also double check that connection info for Mongo from CLI or Compass
j

jolly-chef-93830

02/15/2024, 6:00 AM
It works fine if i send like above, but when I try sending the config.yml file it breaks. trying to follow this approach for MySQL connection. https://docs.growthbook.io/self-host/config#redshift-clickhouse-postgres-and-mysql-or-mariadb config.yml datasources: warehouse: type: mysql name: Main Warehouse # Connection params (different for each type of data source) params: host: localhost port: 3306 user: root password: password # use env for secrets database: growthbook # How to query the data (same for all SQL sources) settings: userIdTypes: - userIdType: user_id description: Logged-in user id - userIdType: anonymous_id description: Anonymous visitor id queries: exposure: - id: user_id name: Logged-in user experiments userIdType: user_id query: > SELECT user_id, received_at as timestamp, experiment_id, variation_id, context_location_country as country FROM experiment_viewed dimensions: - country identityJoins: - ids: ["user_id", "anonymous_id"] query: SELECT user_id, anonymous_id FROM identifies metrics: signups: type: binomial name: Sign Ups userIdType: user_id datasource: warehouse sql: SELECT user_id, anonymous_id, received_at as timestamp FROM signups dimensions: country: name: Country userIdType: user_id datasource: warehouse sql: SELECT user_id, country as value from users segments: visitors: name: Visitors in the US datasource: warehouse sql: |- SELECT userid as user_id, timestamp as date FROM users WHERE country='US' userIdType: user_id
12 Views