Environment Variables
Umami can be configured using environment variables to customize behavior, enable features, and integrate with external services.Required Variables
These variables are required for Umami to function:DATABASE_URL
Database Connection
PostgreSQL database connection string.
APP_SECRET
Application Secret
Random string used for encrypting sessions, tokens, and sensitive data.
Optional Configuration
Application Settings
PORT
Port number for the application server.3000
Cloud platforms like Railway and Vercel automatically set the PORT variable. You usually don’t need to change this.
HOSTNAME
Hostname for the server to bind to.0.0.0.0 (all interfaces)
Options:
0.0.0.0- Accept connections from any interfacelocalhost- Only local connections- Specific IP address
BASE_PATH
Serve Umami from a subdirectory.https://yourdomain.com/analytics
When using BASE_PATH, you must rebuild the application for changes to take effect.
Tracking Configuration
TRACKER_SCRIPT_NAME
Customize the tracking script filename to avoid ad blockers.- Avoid ad blocker detection
- Use branded script names
- Support multiple script names simultaneously
TRACKER_SCRIPT_URL
Serve tracking script from external URL.COLLECT_API_ENDPOINT
Customize the data collection endpoint./api/send
Use this to:
- Avoid ad blocker patterns
- Match your API structure
- Use custom endpoint names
Security Settings
FORCE_SSL
Force HTTPS and add security headers.- Adds
Strict-Transport-Securityheader - Forces HTTPS redirects
- Enhances security posture
ALLOWED_FRAME_URLS
Configure Content Security Policy for embedding Umami in iframes.- Embed Umami dashboard in your app
- Display analytics on your website
- Allow specific domains to frame Umami
CORS_MAX_AGE
CORS preflight cache duration in seconds.86400 (24 hours)
Cloud Mode
CLOUD_MODE
Enable cloud/SaaS mode features.- Multi-tenant features
- Team workspaces
- Usage limits
- Billing integration
Cloud mode is for SaaS deployments. Most self-hosted users don’t need this.
CLOUD_URL
Cloud service URL for remote tracking.Database Options
DATABASE_TYPE
Database type (usually auto-detected).postgresql(default and recommended)mysql(deprecated, not recommended)
Umami v2+ focuses on PostgreSQL. MySQL support is limited and may be removed in future versions.
SKIP_DB_CHECK
Skip database connection check on startup.High-Volume Options
For sites with millions of pageviews:CLICKHOUSE_URL
ClickHouse database for high-volume analytics.- Handle billions of events
- Faster queries on large datasets
- Columnar storage for analytics
ClickHouse is optional and only needed for very high-traffic sites (millions of events per day).
REDIS_URL
Redis for caching and session storage.- Faster session management
- Improved performance
- Distributed caching
Localization
DEFAULT_LOCALE
Default language for the UI.en-US- English (default)es-ES- Spanishfr-FR- Frenchde-DE- Germanzh-CN- Chinese (Simplified)ja-JP- Japaneseko-KR- Koreanpt-BR- Portuguese (Brazil)ru-RU- Russian- And many more…
Build-Time Variables
These affect the build process:NEXT_TELEMETRY_DISABLED
Disable Next.js telemetry.NODE_ENV
Node.js environment mode.production- Optimized builds, no debug infodevelopment- Debug mode, hot reloadtest- Testing environment
NODE_OPTIONS
Node.js runtime options.Setting Environment Variables
Local Development
Create a.env file in the project root:
.env
The
.env file is in .gitignore by default. Never commit it to version control.Docker Compose
Add todocker-compose.yml:
docker-compose.yml
.env file:
docker-compose.yml
Docker Run
Pass variables with-e flag:
Railway
- Go to your Umami service
- Click Variables tab
- Click + New Variable
- Add key and value
- Click Add
Vercel
- Go to Settings → Environment Variables
- Enter variable name and value
- Select environments (Production, Preview, Development)
- Click Save
- Redeploy for changes to take effect
System Environment
For systemd or process managers:systemd service file
Configuration Examples
Minimal Production Setup
.env
Advanced Production
.env
High-Volume Setup
.env
Troubleshooting
Environment variables not loading
Environment variables not loading
Check:
.envfile exists in project root- No syntax errors in
.envfile - Variables don’t have quotes unless needed
- Restart the application after changes
DATABASE_URL not found
DATABASE_URL not found
Make sure:
- Variable is set before building/starting
- No typos in variable name
- Connection string format is correct
- Using
=not:or space
Changes not taking effect
Changes not taking effect
- Rebuild after changing build-time variables (BASE_PATH, TRACKER_SCRIPT_NAME)
- Restart after changing runtime variables
- Clear Next.js cache:
rm -rf .next - In Docker: recreate containers
Invalid APP_SECRET
Invalid APP_SECRET
Requirements:
- Minimum 32 characters recommended
- Use alphanumeric and special characters
- Don’t use spaces
- Base64 encoding recommended
Best Practices
Use Strong Secrets
Generate cryptographically secure random strings for APP_SECRET
Never Commit Secrets
Keep
.env in .gitignore and use secret management toolsDocument Your Config
Create
.env.example with dummy values for team referenceUse Different Secrets
Don’t reuse APP_SECRET across environments or applications
Next Steps
Database Setup
Configure and optimize your database
Running in Production
Production deployment best practices
Docker Installation
Deploy with Docker using environment variables
Quickstart
Get started with Umami