Environment Variables
Reference for the most important `MEMOS_*` runtime settings.
Memos maps runtime flags to environment variables with the MEMOS_ prefix. In production, environment variables are usually the cleanest way to keep deployment config explicit and repeatable.
Reference
All flags and their corresponding environment variables:
| Flag | Environment variable | Default | Purpose |
|---|---|---|---|
--port | MEMOS_PORT | 8081 | HTTP listen port |
--addr | MEMOS_ADDR | `` | Bind address (empty = all interfaces) |
--unix-sock | MEMOS_UNIX_SOCK | `` | Unix socket path |
--data | MEMOS_DATA | auto | Data directory |
--driver | MEMOS_DRIVER | sqlite | Database backend (sqlite, mysql, postgres) |
--dsn | MEMOS_DSN | auto | Database connection string |
--instance-url | MEMOS_INSTANCE_URL | `` | Public instance URL; empty enables private mode |
--demo | MEMOS_DEMO | false | Demo mode |
--allow-private-webhooks | MEMOS_ALLOW_PRIVATE_WEBHOOKS | false | Allow webhook URLs that resolve to private or reserved IP ranges |
--log-level | MEMOS_LOG_LEVEL | info | Log verbosity (debug, info, warn, error) |
Data directory defaults
MEMOS_DATA resolves automatically when not set:
- Windows:
%ProgramData%\memos - Docker:
/var/opt/memos(when writable) - Linux / macOS: current directory (
.)
DSN defaults
When MEMOS_DRIVER=sqlite and MEMOS_DSN is empty, the database file defaults to {MEMOS_DATA}/memos_prod.db. For MySQL and PostgreSQL, MEMOS_DSN is required.
Public and private mode
Since Memos 0.30, an empty MEMOS_INSTANCE_URL puts the instance in private mode. Anonymous visitors are redirected to sign-in, RSS is unavailable, and anonymous API access is limited to setup, authentication, registration when allowed, and shared-memo routes.
Set MEMOS_INSTANCE_URL to the canonical external URL when you intentionally want public profiles, public memos, Explore, RSS, and other anonymous reads. The value must include the scheme, for example https://memos.example.com.
Priority order
- Command-line flags (highest)
- Environment variables
- Default values (lowest)
An explicit flag always wins over the environment variable for the same setting.
Practical guidance
- leave
MEMOS_INSTANCE_URLempty for a private-only instance - set it to the canonical public URL when you want anonymous public access or when the app sits behind a proxy
- prefer explicit
MEMOS_DRIVERandMEMOS_DSNwhen you are not using SQLite defaults - leave
MEMOS_ALLOW_PRIVATE_WEBHOOKSdisabled unless your webhook targets intentionally live on a trusted private network - keep secrets such as database credentials outside committed compose files
- treat these values as part of deployment config and back them up accordingly
Common patterns
SQLite with explicit data directory:
export MEMOS_DRIVER=sqlite
export MEMOS_DATA=/var/opt/memos
./memosExternal PostgreSQL:
export MEMOS_DRIVER=postgres
export MEMOS_DSN="postgres://user:password@db:5432/memos?sslmode=disable"
export MEMOS_INSTANCE_URL=https://memos.example.com
./memosUnix socket with Nginx (useful for local reverse proxy):
export MEMOS_UNIX_SOCK=/var/run/memos.sock
export MEMOS_DATA=/var/lib/memos
export MEMOS_INSTANCE_URL=https://memos.example.com
./memosNginx upstream for the socket:
upstream memos {
server unix:/var/run/memos.sock;
}