Docs Overview Install Configuration API CLI

Configuration Reference

Everything you can set in the configuration file, the environment, or on the command line.

Config file

By default the server looks for config.toml in the working directory. Pass a different path with --config <path>. The file is read once at startup; restart the process after changing it.

Options

KeyTypeDefaultDescription
server.host
optional
string "127.0.0.1" Address to bind. Use "0.0.0.0" to accept connections from other machines.
server.port
optional
integer 8080 TCP port to listen on. Must be between 1 and 65535.
server.workers
optional
integer CPU count Number of worker threads handling requests.
database.url
required
string none Connection URL, for example postgres://user:pass@host/db.
database.max_connections
optional
integer 10 Upper bound on pooled connections per worker.
log.level
optional
string "info" One of debug, info, warn, error.
log.format
optional
string "text" "text" for humans, "json" for log aggregators.
cache.ttl_seconds
optional
integer 300 How long responses are cached. Set to 0 to disable caching.

Environment variables

Every key can be overridden with an environment variable. Replace dots with underscores and prefix with APP_, so server.port becomes APP_SERVER_PORT. Values from the environment always win over the file.

Precedence

Settings are resolved in this order, highest first:

  1. Command-line flags
  2. Environment variables
  3. The config file
  4. Built-in defaults
Secrets. Do not commit database.url with a password to version control. Put it in APP_DATABASE_URL instead.

Example

# config.toml
[server]
host = "0.0.0.0"
port = 8080
workers = 4

[database]
url = "postgres://app@db.internal/app"
max_connections = 20

[log]
level = "info"
format = "json"

[cache]
ttl_seconds = 600

Validate a file without starting the server:

$ app config check --config config.toml
config.toml: ok