Skip to main content

Environment Variables

The default configuration in GrowthBook is optimized for trying things out quickly on a local dev machine. Beyond that, you can customize behavior with Environment Variables.

Domains and Ports

This is used to generate links to GrowthBook and enable CORS access to the API.

  • APP_ORIGIN - default http://localhost:3000
  • API_HOST - default http://localhost:3100

If you want to run GrowthBook on a different host than localhost, you need to add the above environment variables to your docker-compose.yml file.

growthbook:
...
environment:
- APP_ORIGIN=http://<my ip>:3000
- API_HOST=http://<my ip>:3100
Unique ports on the same domain

The back-end and the front-end must run on unique ports if on the same domain.

The front-end has its own set of /api routes so currently we do not support running both the API and the front-end on the same port on the same domain.

Important

In order for authentication cookies to work correctly, both the app and api domains must be considered the "same site". They can be on different subdomains or ports, but the root domain must be the same.

  • Works: gb.example.com and gb-api.example.com
  • Breaks: gb.frontend.com and gb.backend.com

If you need to change the ports on your local dev environment (e.g. if 3000 is already being used), you need to update the above variables AND change the port mapping in docker-compose.yml:

growthbook:
ports:
- "4000:3000" # example: use 4000 instead of 3000 for the app
- "4100:3100" # example: use 4100 instead of 3100 for the api
...
environment:
- APP_ORIGIN=http://<my ip or url>:4000
- API_HOST=http://<my ip or url>:4100

Production Settings

  • NODE_ENV - Set to "production" to turn on additional optimizations and API request logging
  • MONGODB_URI - The full MongoDB connection string. Alternatively you can specify the following environment variables from which we will compose the full connection string like so mongodb://${MONGODB_USERNAME}:${MONGODB_PASSWORD}@${MONGODB_HOSTNAME}:${MONGODB_PORT}/${MONGODB_DBNAME}${MONGODB_EXTRA_ARGS}:
    • MONGODB_USERNAME - Username for MongoDB
    • MONGODB_PASSWORD - Password for MongoDB
    • MONGODB_HOST - Host name of MongoDB excluding port, e.g. some.host.com
    • MONGODB_PORT - Port to use for MongoDB (defaults to 27017)
    • MONGODB_DBNAME - Database name of growthbook database (defaults to growthbook)
    • MONGODB_EXTRA_ARGS - Optional set of extra arguments for MongoDB connection string (defaults to ?authSource=admin)
  • JWT_SECRET - Auth signing key (use a long random string)
  • ENCRYPTION_KEY - Data source credential encryption key (use a long random string)

If you change the ENCRYPTION_KEY, you will need to migrate any existing data sources using the following script:

# If you didn't have an ENCRYPTION_KEY before, leave OLD_KEY blank below
docker-compose run growthbook yarn migrate-encryption-key OLD_KEY
Important

When using GrowthBook in production, it is important to change the

NODE_ENV to to "production" and change theJWT_SECRET to a random string. Using the productionnode environment and the default JWT_SECRET will throw an error.

Email SMTP Settings

This is required in order to send experiment alerts, team member invites, and reset password emails.

  • EMAIL_ENABLED ("true" or "false")
  • EMAIL_HOST
  • EMAIL_PORT
  • EMAIL_HOST_USER
  • EMAIL_HOST_PASSWORD
  • EMAIL_FROM

Google OAuth Settings

Only required if using Google Analytics as a data source

  • GOOGLE_OAUTH_CLIENT_ID
  • GOOGLE_OAUTH_CLIENT_SECRET

File Uploads

The UPLOAD_METHOD environment variable controls where to store uploaded files and screenshots. The supported values are local, s3, and google-cloud.

local

This is the default value. Uploads are stored in the GrowthBook docker container at /usr/local/src/app/packages/back-end/uploads. In production, you should mount a volume here to persist uploads across container restarts.

s3

Store uploads in an AWS S3 bucket.

  • S3_BUCKET
  • S3_REGION (defaults to us-east-1)
  • S3_DOMAIN (defaults to https://${S3_BUCKET}.s3.amazonaws.com/)
  • AWS_ACCESS_KEY_ID (not required when deployed to AWS with an instance role)
  • AWS_SECRET_ACCESS_KEY (not required when deployed to AWS with an instance role)
  • USE_FILE_PROXY set this to true for access to uploads to proxy through your self hosted server allowing you to keep the bucket private.

google-cloud

Store uploads in a Google Cloud Storage bucket.

  • GCS_BUCKET_NAME
  • GCS_DOMAIN (defaults to https://storage.googleapis.com/${GCS_BUCKET_NAME}/)
  • GOOGLE_APPLICATION_CREDENTIALS (not required when deployed to GCP with an instance service account)
  • USE_FILE_PROXY set this to true for access to uploads to proxy through your self hosted server allowing you to keep the bucket private.

Enterprise Settings

Some features in self-hosted GrowthBook are only available with a commercial license key. You can get a trial Enterprise key from your self-hosted version of GrowthBook, or reach out to sales@growthbook.io to learn more.

License Keys

If you have a license key, you can activate it in GrowthBook two different ways:

  1. Navigate to Settings > General and look for the License section of the page. There you can input or edit your license key string. (Recommended)
  2. Alternately, set the environment variable LICENSE_KEY to your license key string. If using Docker, go to docker-compose.yml and add the variable to the growthbook > environment section.
note

If you are running your application behind a firewall you will need to whitelist 75.2.109.47 to be able to have your license verified. If this is an issue, contact sales@growthbook.io for an air-gapped license.

The GrowthBook app will check with the license server daily to get the latest license information. When doing so, it will send the following data to our license server:

  • A hash of each user's email - this is used to deduplicate users across multiple installations (dev, prod, etc.) in order to figure out how many seats are being used.
  • The git sha and date of the installation - this is used to determine when GrowthBook can delete deprecated features, determine who to send upgrade notices to, provides helpful information for debugging, etc.
  • A list of which data source types are being used, a list of which event trackers are being used, and a list of SDK languages being used - these help GrowthBook know how much usage the various data sources, event trackers, and sdk languages are getting so we can prioritize work.

If you recently upgraded your license and do not want to wait a day to get the new license information you can go to Settings > General and look for the License section of the page and click the Refresh button. If you have a multi-org installation and are a super admin you must instead navigate to the Settings > Admin page, find the license section and click the refresh button there.

Enterprise SSO

To enable SSO on your self-hosted GrowthBook instance, you will need an active license key (see above section), and then you may add the SSO settings for your provider. You can find the instructions on how to setup SSO for GrowthBook with most common providers on our SSO instructions page. The JSON object with the settings will need to be JSON encoded and then set to the environment variable SSO_CONFIG.

Observability (OpenTelemetry)

The GrowthBook API is instrumented with OpenTelemetry to publish observability metrics, traces, and logs.

To enable, you must change the Docker CMD from the default yarn start to yarn start:with-tracing.

The standard OTEL_* Environment Variables are supported, such as OTEL_SERVICE_NAME and OTEL_EXPORTER_OTLP_ENDPOINT.

Other Settings

  • EXPERIMENT_REFRESH_FREQUENCY - Default update schedule for experiment results. Update when stale for X hours (default 6).
  • QUERY_CACHE_TTL_MINS - How long (in minutes) to cache and re-use SQL query results (default 60)
  • DEFAULT_CONVERSION_WINDOW_HOURS - How many hours after being put into an experiment does a user have to convert. Can be overridden on a per-metric basis. (default 72)
  • DISABLE_TELEMETRY - We collect anonymous telemetry data to help us improve GrowthBook. Set to "true" to disable.
  • STORE_SEGMENTS_IN_MONGO - If using the config.yml file, set to true if you want to store segments in Mongo. This is also useful if you have existing segments stored in Mongo that you need to access. When set, GrowthBook will ignore segments in the config.yml file and only use Segments stored in Mongo.
  • CDN_HOST - When set, this will update the implementation instructions within GrowthBook to override the API_HOST in cases where a CDN is used.
  • EXPRESS_TRUST_PROXY_OPTS - Express' trust proxy setting value. Supports boolean (true/false), string values, and integer values for trusting the nth hop from the front-facing proxy server as the client. Leavy empty or specify false to use Express' default behavior. If you are running GrowthBook behind a proxy or load balancer, this is required to track the correct user IP for audit log events.