Skip to main content
Spree uses environment variables for all deployment configuration. No secrets or credentials are stored in the codebase.

Required

These variables are required to run Spree in production.
VariableDescriptionExample
DATABASE_URLPostgreSQL connection URLpostgres://user:pass@localhost:5432/spree
REDIS_URLRedis URL for background jobs (Sidekiq) and Action Cableredis://localhost:6379/0
REDIS_CACHE_URLRedis URL for caching (optional — falls back to REDIS_URL)redis://localhost:6380/0
SECRET_KEY_BASESecret key for session encryption. Generate with bin/rails secret2fad5c0b79d25e4765d3018d8c740f8c3a665f0e5c...

Email (SMTP)

Spree works with any SMTP provider (Resend, Postmark, Mailgun, SendGrid, Amazon SES, etc.). Set SMTP_HOST to enable email delivery — when not set, emails are logged to stdout.
VariableDefaultDescription
SMTP_HOSTSMTP server address (e.g., smtp.sendgrid.net)
SMTP_PORT587SMTP server port
SMTP_USERNAMESMTP auth username
SMTP_PASSWORDSMTP auth password
SMTP_FROM_ADDRESSDefault “from” email address
RAILS_HOSTexample.comHost used in email URLs

Web Server

VariableDefaultDescription
PORT3000Web server port
RAILS_MAX_THREADS3Puma threads per worker
WEB_CONCURRENCY1Number of Puma workers. Set to auto for one per CPU core

Application

VariableDefaultDescription
RAILS_ENVproductionRails environment
RAILS_LOG_LEVELinfoLog level (debug, info, warn, error)

File Storage (S3 / Cloudflare R2)

By default, uploaded files (product images, assets) are stored on the local filesystem. Set the appropriate credentials to use cloud storage instead. Spree auto-detects the provider based on which credentials are present.

Amazon S3

VariableDefaultDescription
AWS_ACCESS_KEY_IDAWS access key
AWS_SECRET_ACCESS_KEYAWS secret key
AWS_REGIONAWS region (e.g., us-east-1)
AWS_BUCKETspree-productionS3 bucket name

Cloudflare R2

VariableDefaultDescription
CLOUDFLARE_ENDPOINTR2 endpoint URL
CLOUDFLARE_ACCESS_KEY_IDR2 access key
CLOUDFLARE_SECRET_ACCESS_KEYR2 secret key
CLOUDFLARE_BUCKETspree-productionR2 bucket name

Search (Meilisearch)

Optional. When configured, Spree uses Meilisearch for product search, filtering, and faceted navigation instead of SQL.
VariableDefaultDescription
MEILISEARCH_URLhttp://localhost:7700Meilisearch server URL
MEILISEARCH_API_KEYMeilisearch master key. Not needed for local development — only required when Meilisearch is started with MEILI_MASTER_KEY.
After setting these, enable the provider and reindex:
# config/initializers/spree.rb
Spree.search_provider = 'Spree::SearchProvider::Meilisearch'
rake spree:search:reindex

Error Tracking (Sentry)

VariableDefaultDescription
SENTRY_DSNSentry DSN. When set, errors are reported to Sentry

SSL

By default, Spree assumes it runs behind an SSL-terminating reverse proxy. Set these to false if running without SSL (e.g., local development or behind a proxy that doesn’t do SSL termination).
VariableDefaultDescription
RAILS_ASSUME_SSLtrueAssume requests arrive via SSL (sets X-Forwarded-Proto)
RAILS_FORCE_SSLtrueRedirect HTTP to HTTPS and use secure cookies

Local Development

These variables are used when running the server/ app locally (not via DATABASE_URL):
VariableDefaultDescription
DATABASE_HOSTlocalhostPostgreSQL host
DATABASE_PORT5432PostgreSQL port
DATABASE_USERNAMEpostgresPostgreSQL user