This page explains the main environment variables used by self-hosted AFFiNE. Docker Compose users should set persistent paths and database credentials before the first start, because changing them after data exists can require a backup-and-restore workflow.
| Variable | Description | Default |
|---|---|---|
| AFFINE_REVISION | The AFFiNE revision to deploy. Available values are stable, beta, and canary. | stable |
| DB_DATA_LOCATION | Location of the Postgres data directory to persist. | |
| UPLOAD_LOCATION | Location of uploaded blobs, such as images and files, to persist. | |
| CONFIG_LOCATION | Location of user custom configuration files to persist. |
| Variable | Description | Default |
|---|---|---|
| AFFINE_PRIVATE_KEY | Private key used by the crypto module to create signed tokens or encrypt data. If not provided, AFFiNE auto-generates one under CONFIG_LOCATION on first start. | |
| AFFINE_SERVER_HTTPS | Whether the server is hosted on an SSL/TLS-enabled domain. | false |
| AFFINE_SERVER_HOST | Fully qualified domain name where the server is deployed. | localhost |
| AFFINE_SERVER_PORT | Port the server listens on inside the container. | 3010 |
| AFFINE_SERVER_SUB_PATH | Subpath where the server is deployed, if any. | |
| AFFINE_SERVER_EXTERNAL_URL | Base URL of the AFFiNE server, used for generating external links. Defaults to [server.protocol]://[server.host][:server.port] if not specified. |
For production, configure Domain and HTTPS and make sure generated invitation links and public doc links use the correct external URL.
| Variable | Description | Default |
|---|---|---|
| DATABASE_URL | Database URL passed to the server if you are not using Docker Compose. | |
| DB_USERNAME | Database user. | affine |
| DB_PASSWORD | Database password. Docker Compose users should set a strong password before the first start to initialize Postgres safely. | |
| DB_DATABASE | Database name. | affine |
Set DB_PASSWORD before your first Docker Compose start. Using POSTGRES_HOST_AUTH_METHOD=trust disables password authentication and should only be used in controlled local or test environments.
| Variable | Description | Default |
|---|---|---|
| REDIS_SERVER_HOST | Redis host. | localhost |
| REDIS_SERVER_PORT | Redis port. | 6379 |
| REDIS_SERVER_USERNAME | Redis username. | |
| REDIS_SERVER_PASSWORD | Redis password. | |
| REDIS_SERVER_DATABASE | Redis database index used by AFFiNE. If n is set as REDIS_SERVER_DATABASE, AFFiNE uses databases from n to n+4 for different purposes. | 0 |
| Variable | Description | Default |
|---|---|---|
| MAILER_HOST | Host of the email server, such as smtp.gmail.com. | |
| MAILER_PORT | Port of the email server. Common ports are 25, 465, and 587. | 465 |
| MAILER_USER | Username used to authenticate with the email server. | |
| MAILER_PASSWORD | Password used to authenticate with the email server. | |
| MAILER_SENDER | Sender of all emails, for example AFFiNE Team <[email protected]>. | |
| MAILER_IGNORE_TLS | Whether to ignore the email server TLS certificate verification. Enable only for self-signed certificates you trust. |
*You need an app password for services like Gmail: Source1, Source2.