Configuration
Every setting in deploy/.env: required values, sign-in, email, uploads, agents, modules and the Xero connection.
All settings live in deploy/.env. Copy deploy/env.example to start, and apply a change with docker compose --env-file deploy/.env up -d.
Required
| Setting | Meaning |
|---|---|
APP_URL | The address people use. It must match exactly: sign-in cookies, links in emails and the MCP host check all use it. |
BETTER_AUTH_SECRET | At least 32 random characters. It also encrypts connected-calendar tokens and keys the attendance kiosk PINs, so changing or losing it signs everyone out, breaks calendar connections and invalidates every kiosk PIN. |
POSTGRES_PASSWORD | The bundled database's password. Required, with no default. Letters and digits only. |
Sign-in
| Setting | Meaning |
|---|---|
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET | Adds Continue with Google. Set the callback URL to APP_URL/api/auth/callback/google. |
GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET | Adds Continue with GitHub, with the callback at APP_URL/api/auth/callback/github. |
MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET, MICROSOFT_TENANT_ID | Adds Continue with Microsoft, with the callback at APP_URL/api/auth/callback/microsoft. The tenant defaults to common. |
TRUSTED_ORIGINS | Other addresses for the same server, such as an IP and a hostname, separated by commas. |
SETUP_TOKEN | A fixed first-run setup code, instead of a random one printed in the log. |
Social sign-in still admits invited addresses only, and the server needs to reach the internet for it.
Email is optional. Without it, invitations and password resets are shared as links and QR codes. To send them by email, set both values:
SMTP_URL=smtps://USER:PASSWORD@smtp.example.com:465 # TLS from the first byte
# SMTP_URL=smtp://USER:PASSWORD@smtp.example.com:587 # upgrades with STARTTLS
MAIL_FROM=Knotworking <knotworking@example.com>
- URL-encode special characters in the username and password:
@becomes%40. MAIL_FROMmust be a sender your provider accepts. Without it, the fallback is a localhost address that almost every provider rejects.- If sending fails, the invitation is still created and the admin sees the link to share by hand.
File uploads
Attachments go to the uploads Docker volume by default. They are never public: every download goes through the API, with the same sign-in and membership checks as the rest of the app. Only PNG, JPEG, GIF and WebP images show inline. Everything else downloads as a file, so an upload can never run script on your domain.
| Setting | Meaning |
|---|---|
UPLOAD_MAX_BYTES | Largest single file. Default 10485760 (10 MB), at most 1 GiB. |
UPLOAD_STORAGE | Set to s3 to use an S3-compatible bucket (AWS, R2, B2, MinIO) instead of the volume. |
S3_BUCKET, S3_REGION, S3_ENDPOINT | The bucket, its region (auto for R2) and, outside AWS, its endpoint. |
S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY | A key limited to that bucket: PutObject, GetObject and DeleteObject. |
S3_FORCE_PATH_STYLE | Set to true for MinIO and some other S3-compatible services. |
S3_PREFIX | An optional key prefix, such as knotworking/. |
Ports and addresses
| Setting | Meaning |
|---|---|
HTTP_PORT | The host port Caddy serves plain HTTP on. Default 3000. Use 80 with a domain. |
HTTPS_PORT | The host port for HTTPS. Default 443, published only when HTTPS is on. |
DOMAIN | The domain Caddy gets a certificate for. See HTTPS and proxies. |
API_HOST | The address the API listens on. Run standalone, it defaults to 127.0.0.1 (this machine only). The bundled Compose stack sets 0.0.0.0 inside its private network and never publishes the port. Leave it alone unless a proxy on another machine must reach the API. |
DATABASE_URL, MIGRATE_DATABASE_URL, DATABASE_POOL_SIZE, DATABASE_POOLED | Use a hosted database instead of the bundled one, and tune its connections. See Database. |
See HTTPS and proxies, including keeping the API private, and Database.
Calendar sync
Calendar sync is a flagged module and is off by default. To turn it on, name calendar in KNOTWORKING_MODULES, or use all. People then connect their own Google or Microsoft calendar.
- It uses the same Google and Microsoft credentials as sign-in.
APP_URLmust be HTTPS on a real domain, because Google and Microsoft only accept HTTPS redirect URLs. The server also needs to reach their APIs.CALENDAR_SYNC_INTERVAL_SECONDSsets how often each connected calendar is checked. Default 300.
The provider adapters are tested against a fake calendar service, not live accounts. See Optional integrations.
Modules and agents
| Setting | Default | Meaning |
|---|---|---|
KNOTWORKING_MODULES | Every module except Calendar, Dashboards, Invoicing and Accounting | Which modules this server offers. Each workspace then chooses from them, and each person is granted them. An explicit list must include required dependencies; it does not automatically include new modules after an upgrade. See Modules for upgrade details. |
KNOTWORKING_DEFAULT_WORKSPACE | None | The workspace slug agents use when they don't name one. |
MCP_ALLOWED_HOSTS | Localhost, plus the hosts in APP_URL and TRUSTED_ORIGINS | Hostnames accepted in the Host and Origin headers of MCP requests, separated by commas, without ports. |
MCP_RATE_LIMIT_PER_MINUTE | 120 | Tool calls per token per minute. 0 turns it off. |
MCP_MAX_BATCH | 10 | Most JSON-RPC calls accepted in one HTTP request. |
API_TOKEN_READ_LIMIT_PER_MINUTE | 600 | Reads the API allows per token per minute. |
API_TOKEN_WRITE_LIMIT_PER_MINUTE | 120 | Writes the API allows per token per minute. |
Rate limits are counted in memory per process, so a restart resets them. More in Agents and MCP.
Xero connection
The Accounting module can connect a workspace to Xero and send approved supplier bills, issued customer invoices and credit notes. It is a flagged module and is off by default. Xero is the only accounting system it supports, and it keeps the ledger, tax filing and payments. See How the Xero connection works.
- In the Xero Developer Portal, create a Web app. To try it first, use a Xero Demo Company with the base currency you intend to use.
- Register the redirect URI
APP_URL/api/v1/accounting/xero/callback, with your ownAPP_URLin place of the first part.APP_URLmust be the web origin only: scheme, host and port, with no path. Keep it the same once bills are sent, because each bill links back to it. Xero wants HTTPS, and allowshttp://localhostwith a port for local testing. - Set the values below in
deploy/.env, nameaccountinginKNOTWORKING_MODULES(or useall), then restart. Keep Items and Purchasing available for the people who review documents, and Stock for stocked purchases. - Open Accounting connections as an owner or admin and save a setup. Choose Connect Xero and authorise, then Review organisation, compare the name and currency, and choose Confirm organisation and currency. Use Verify connection to check it again later.
- Save the reviewed mappings for contacts, accounts and tax rates, prepare documents, and send them from the accounting queue. Knotworking maps to contacts and accounts that already exist in Xero. It doesn't create them.
| Setting | Default | Meaning |
|---|---|---|
XERO_CLIENT_ID | None | The client ID of your Xero app. |
XERO_CLIENT_SECRET | None | The client secret of your Xero app. |
BETTER_AUTH_SECRET | None | Private and at least 32 characters. The server won't start Xero posting with a short or development secret. It also protects the stored Xero tokens, so changing it means reconnecting. |
ACCOUNTING_DISPATCH_INTERVAL_SECONDS | 300 | How often queued documents are sent, in seconds. 0 sends only when someone chooses Send now. |
Use the same values on every API worker. Knotworking asks Xero for offline_access, accounting.invoices, accounting.settings.read and accounting.contacts.read. Tokens are stored on the server only, encrypted.