On this page
- 1. Where the file lives and when it takes effect
- 2. Syntax rules (the usual culprit)
- 3. Core variables
- 4. Email and registration
- 4.1 SMTP variables
- 4.2 Common SMTP failures
- 5. AI models (agix)
- 6. Connectors and approval origins (not resource config in .env)
- 6.1 provider unavailable
- 6.2 403 非法 Origin
- 6.3 CORS
- 7. Ports and networking
- 8. Security checklist
- 9. Verify after changes
Environment variable troubleshooting
Last updated: 2026-11-10
This page collects the most common .env configuration problems. Every example uses placeholders. Never put real keys, authorization codes or administrator passwords into documentation, tickets or chat logs.
1. Where the file lives and when it takes effect
- The file lives in the deployment root (next to
wasmx.json) and is referenced bywasmx.json’senv_file, default.env. - Set restrictive permissions:
chmod 600 .env
- Changes require a host restart; container deployments need a container restart/recreate:
wasmx stop . && wasmx start .
- The log is
wasmx.login the deployment directory. On startup failure, read the last 20 lines first.
2. Syntax rules (the usual culprit)
Use KEY=VALUE, one variable per line:
- Do not put spaces around
=:KEY = valueis not valid. - Quote values containing spaces, non-ASCII characters,
#or quotes:
SMTP_FROM_NAME='Keragi notifications'
SMTP_PASSWORD='authorization-code-with-#'
- An unquoted
#starts a comment, so the value is truncated there. Authorization codes and random secrets containing#must be quoted. - Do not write
export KEY=...; dotenv does not parse shell syntax. - An empty value (
KEY=) is not the same as an unset variable: required values left empty are usually treated as missing. Error parsing line: '...'on startup usually means an unquoted space/quote or a misplaced inline comment.
3. Core variables
| Variable | Purpose | Common problem |
|---|---|---|
WASMX_ADDR | Listen address | Containers must use 0.0.0.0:3001; bare metal should use 127.0.0.1:3001 behind a proxy |
WASMX_DB | Host SQLite URL | Needs a writable directory and a persistent volume in containers; resource databases use *_DB_URL |
JWT_SECRET | Shared signing secret for the host and userx | At least 32 random characters; changing it invalidates all existing tokens |
OPEN_REGISTRATION | Allow self-service sign-up | Turn off when not needed in production |
BOOTSTRAP_ADMIN_CREDENTIAL | Administrator created on first start | Only applies when the database is empty; changing it later does not change an existing password |
BOOTSTRAP_ADMIN_PASSWORD | Initial administrator password | Use upper/lower case, digits and a special character |
USERX_ADMIN_URL | Internal URL the host uses for userx | Must match WASMX_ADDR and the resource prefix |
USERX_PUBLIC_URL | userx URL used by clients | Use the public URL when behind a proxy or same-origin deployment |
USERX_ADMIN_CREDENTIAL / USERX_ADMIN_PASSWORD | Admin credentials the host uses for userx | Must match the bootstrap administrator |
4. Email and registration
4.1 SMTP variables
| Variable | Description |
|---|---|
SMTP_HOST | SMTP server |
SMTP_PORT | Port; 465 for implicit TLS, 587 for STARTTLS |
SMTP_TLS | implicit or starttls |
SMTP_USERNAME | Login account; also used as the From address |
SMTP_PASSWORD | Authorization code / app password (not the mailbox login password) |
SMTP_FROM_NAME | Display name; quote it if it contains spaces or non-ASCII characters |
4.2 Common SMTP failures
| Symptom | Cause | Fix |
|---|---|---|
535 authentication failed | Wrong host, mailbox password used instead of an authorization code, or an unquoted # in the code | Enterprise mail usually needs smtp.qiye.163.com; personal mail uses smtp.163.com. Quote the code with single quotes |
Startup log says SMTP 未配置 | The three required variables (host / username / password) are not all present | Configure all three and restart |
| No verification email | Message filtered, From differs from the account, or rate limit | Check wasmx.log, spam, and the From address; SMTP_USERNAME must be the sender |
| The API returns the plaintext code | The operator enabled a development-only debug switch | Ask the operator to disable it and restart; production must never return plaintext codes |
| No sign-up entry on the login page | OPEN_REGISTRATION=false | Set it to true and restart, or create accounts as admin only |
To verify email delivery, call the captcha endpoint with a real mailbox you can read, then check the log and inbox. Never write the test authorization code into any document.
5. AI models (agix)
If an AI conversation reports:
model 'deepseek-flash' not configured
the model catalog contains that registry name, but no provider resolved for it. Ask the user to add their key in the client under Settings → AI assistant → Model key configuration. Keep only the base URL in the server .env:
AGIX_DEFAULT_MODEL=deepseek-flash
AGIX_DEEPSEEK_URL=https://api.deepseek.com/v1
Do not put a shared model key in .env for convenience: it leaks through backups and logs and bills every user to one credential.
Notes:
GET /agix/v1/modelslisting a model does not mean its provider is configured; the catalog is always listed.- The registry name (e.g.
deepseek-flash) and the upstream model id (e.g.deepseek-chat) can differ. - Restart after changing
.env; container deployments must update their secrets/env. - Never put model API keys into the frontend
config.jsonor the repository.
Verify:
curl -X POST http://127.0.0.1:3001/agix/v1/responses \
-H "Authorization: Bearer <token>" -H 'Content-Type: application/json' \
-d '{"model":"deepseek-flash","input":"Reply with exactly OK"}'
6. Connectors and approval origins (not resource config in .env)
6.1 provider unavailable
conn.providers in wasmx.json is an explicit list, empty by default:
"providers": ["claude", "codex"]
- The matching CLI must be executable on the host’s
PATHand use that CLI’s own login state. - Declaring a provider does not install the CLI; missing CLIs are skipped with a log line.
- Restart after editing
wasmx.json. - Cloud Workers cannot spawn local CLIs (
claude/codex); use an HTTP-based agent provider or deploy the connector separately.
6.2 403 非法 Origin
The approval page validates the request origin. When accessed through a reverse proxy or another port, the operator must add the actual access origin to the approval allowlist and restart; a restart clears pending approvals.
6.3 CORS
Same-origin deployments need no CORS. If the frontend and API are on different servers, prefer reverse-proxying the four resource paths from the frontend server. If cross-origin is unavoidable, list the origins explicitly:
WASMX_CORS_ORIGINS=https://app.example.com,https://app.keragi.com
- When
WASMX_CORS_ORIGINSis unset,https://app.keragi.comis allowed by default. An explicit list overrides that default. *is rejected; use fullscheme://host[:port]origins.- The Linux desktop client uses
http://tauri.localhost; Android needsWASMX_CORS_ALLOW_LOOPBACK=1. - Prefer same-origin deployment (static hosting plus a reverse proxy) to avoid maintaining both CORS and approval-origin settings.
7. Ports and networking
WASMX_ADDR=127.0.0.1:3001: local access only, suitable behind a reverse proxy.- Containers must bind
0.0.0.0; control exposure at the port mapping/proxy layer. Address already in use: another process owns the port. Stop it or choose another port.- When the frontend goes through a same-origin gateway, make sure
/userx/msgx/agix/connare proxied to the host and that WebSocket upgrades are forwarded.
8. Security checklist
- Never commit
.env; keep it at600; inject secrets through the platform’s secret store or--env-filein containers. - Use a random
JWT_SECRETof at least 32 characters; rotating it logs every session out. - Never return plaintext captcha codes in production; disable
OPEN_REGISTRATIONwhen not needed. - The bootstrap administrator password is for first start only; change it after going live.
- Keep email authorization codes, model API keys and admin passwords out of screenshots, logs, docs and tickets.
- Expose only the reverse proxy/TLS endpoint; never publish
0.0.0.0:3001directly. - Back up
data/anduploads/regularly; SQLite has a single writer, so do not run multiple replicas writing the same files.
9. Verify after changes
wasmx status .
Check wasmx.log for startup lines such as SMTP 已配置 and agent backend 已注册. If it is still broken after 30 seconds, roll .env back to the last known-good version and add changes back one at a time.