Every framework env var now requires the TINA4_ prefix. The legacy un-prefixed names (DATABASE_URL, SECRET, SMTP_HOST, HOST_NAME, etc.) no longer work. Setting them at startup makes the framework refuse to boot with a list of renames.
Run tina4 env --migrate to rewrite your existing .env automatically, or rename manually using the table below. The runtime guard prints the same mapping if it detects legacy names.
Conventional names stay un-prefixed:PORT, HOST, NODE_ENV, RACK_ENV, RUBY_ENV, ENVIRONMENT. These are runtime/PaaS conventions, not framework config.
Tina4 Ruby is configured through environment variables, read from .env at the project root. Every variable has a sensible default, so most projects set three or four values and leave the rest alone.
This chapter lists every variable the Ruby framework reads, grouped by subsystem. Start with the minimum-config examples at the end, then come back here when you need to tune something specific.
Bind address. 0.0.0.0 listens on every interface. 127.0.0.1 restricts to localhost.
TINA4_HOST
(inherits HOST)
Tina4-specific alias for HOST.
PORT
7147
HTTP server port. The Rust CLI prefers TINA4_PORT but falls back to PORT.
TINA4_PORT
(inherits PORT)
Explicit Tina4-specific port override. Takes precedence over PORT when both are set.
TINA4_HOST_NAME
localhost:7147
Fully-qualified host used in generated absolute URLs (Swagger, OAuth redirects, emails).
TINA4_DEBUG
false
Master debug toggle. Enables Swagger UI, dev dashboard, live reload, template dump filter, error overlay. Never set to true in production.
TINA4_STRICT_DISCOVER
unset
Whether a file in src/ that fails to load stops startup. Unset, startup stops outside debug (it exits naming the file) and carries on in debug, so a typo never kills the dev server. true makes a debug start strict too; false serves without the broken file, as before 3.13.169 (ADR-0112).
TINA4_ENV
development
Runtime environment label. Values like development, staging, production control dev-only features. Falls back to RACK_ENV then RUBY_ENV.
RACK_ENV
(none)
Rack-standard environment label. Used if TINA4_ENV is unset.
RUBY_ENV
(none)
Ruby-ecosystem environment label. Used if TINA4_ENV and RACK_ENV are unset.
TINA4_NO_BROWSER
false
Stops tina4 serve from opening your browser on every restart. Recommended during active development.
TINA4_NO_RELOAD
false
Disables the dev hot-reload signal from the Rust CLI. Use when you want a stable server for debugging.
ENVIRONMENT
(none)
PaaS-style environment label. Read by tooling alongside RACK_ENV/RUBY_ENV.
TINA4_SHUTDOWN_TIMEOUT
30
Seconds a graceful shutdown (SIGTERM or SIGINT) waits for in-flight requests before it force-closes them. Under Puma it becomes force_shutdown_after. An invalid or negative value warns and keeps 30.
TINA4_REQUEST_TIMEOUT
30
Built-in server: seconds a client may stay silent. Partway through a request it gets 408; between two requests the idle keep-alive connection closes quietly. 0 switches the timer off.
TINA4_SUPERVISOR_URL
(derived from TINA4_PORT + 2000)
Override URL for the local Rust CLI supervisor used by the dev dashboard.
TINA4_TEMPLATE_ROUTING
on
Controls automatic template-to-route binding. Set to off, false, 0, no, or disabled to require explicit route declarations.
TINA4_ALLOW_LEGACY_ENV
false
Bypass the v3.12 legacy-env startup guard. Intended for CI/migration scripts only.
TINA4_SUPPRESS
false
Suppresses the startup banner. Useful for headless processes and CI runs.
TINA4_ENV_FILE
.env
Path or filename of the dotenv file loaded at boot. Resolved against the project root when relative.
TINA4_HEALTH_PATH
/__health
Liveness route mounted by Tina4::Health. The legacy /health path stays registered as an alias unless it's the configured value. The body is {status, uptime, framework}, plus version when TINA4_DEBUG=true.
JWT signing secret, at least 32 bytes (openssl rand -hex 32). There is no built-in default: a blank or shorter secret is refused. Must be unique per environment. Never commit.
TINA4_TOKEN_EXPIRES_IN
60
Default JWT lifetime in minutes, for every token helper and Frond form tokens. Wins over TINA4_TOKEN_LIMIT when both are set. A value that isn't a positive whole number gives 60 with one warning.
TINA4_TOKEN_LIMIT
60
Older name for the default lifetime in minutes, read when TINA4_TOKEN_EXPIRES_IN is unset. Same rules.
TINA4_JWT_ALGORITHM
HS256
JWT signing algorithm.
TINA4_API_KEY
(empty)
Static API key. Sent as Authorization: Bearer <key>, it opens secured routes with no user attached (request.user is nil), so role/can routes answer 403 to it, and a write it authenticates skips the CSRF check. Read from the Bearer header only. Unset means off.
Connection URL. Scheme selects the driver: sqlite, postgres, mysql, firebird.
TINA4_DATABASE_USERNAME
(empty)
Overrides the username embedded in TINA4_DATABASE_URL.
TINA4_DATABASE_PASSWORD
(empty)
Overrides the password embedded in TINA4_DATABASE_URL.
TINA4_DATABASE_FIREBIRD_PATH
(empty)
Overrides the database path/alias parsed from TINA4_DATABASE_URL for Firebird. Useful for Windows backslash paths and split-config setups.
TINA4_DATABASE_URL
(empty)
Legacy alias for TINA4_DATABASE_URL.
TINA4_AUTOCOMMIT
true
Standalone writes auto-commit on their own connection (durable + visible across a pool); explicit transactions stay atomic. Set false for strict manual-commit mode.
TINA4_DB_CACHE
false
Enables in-memory query-result caching for read queries.
TINA4_DB_CACHE_TTL
30
Query cache TTL in seconds when TINA4_DB_CACHE=true.
TINA4_ORM_PLURAL_TABLE_NAMES
true
When true, the ORM pluralises class names into table names (User → users). Set false to keep them singular.
TINA4_DB_POOL
10
Connection pool size used by Tina4::Database.new(url, pool:) when the caller doesn't pass pool: explicitly. Connections open as they are needed. 0 uses a single connection, lent to one thread at a time.
TINA4_DB_POOL_TIMEOUT
30
Seconds a request waits for a free database connection when every one is lent out. After that it fails with an error naming TINA4_DB_POOL. 0 or less waits forever.
TINA4_DB_RECONNECT_RETRY
true
When the database connection drops, reconnect, replay the connect hooks, and run the failed statement once more. A statement is never re-run inside a transaction the server had open. Set false if each request keeps session state the hooks can't replay, such as row-level security set with set_config (ADR-0110).
Comma-separated allowed origins. Empty denies every cross-origin request; set the origins your front end is served from. * allows any origin and has to be set explicitly.
CSRF token validation on POST/PUT/PATCH/DELETE. Off by default in Ruby; enable with true.
TINA4_HSTS
(empty/off)
Strict-Transport-Security max-age in seconds. Set 31536000 in production with HTTPS.
TINA4_FRAME_OPTIONS
SAMEORIGIN
X-Frame-Options header.
TINA4_REFERRER_POLICY
strict-origin-when-cross-origin
Referrer-Policy header.
TINA4_PERMISSIONS_POLICY
camera=(), microphone=(), geolocation=()
Permissions-Policy header.
TINA4_COOP
same-origin-allow-popups
Cross-Origin-Opener-Policy header. The default keeps OAuth and payment popups working; set same-origin for a fully isolated context (pairs with a COEP header to unlock SharedArrayBuffer).
Behind a load balancer the real client IP rides in a forwarded header. Tina4 will only trust that header when the peer is a proxy you have listed in TINA4_TRUSTED_PROXIES. The outbound guard runs the other way: it will refuse a request aimed at a private address unless TINA4_ALLOW_PRIVATE_REQUESTS opts out.
Variable
Default
Description
TINA4_TRUSTED_PROXIES
(empty)
Comma-separated list of proxy IPs or Classless Inter-Domain Routing (CIDR) ranges whose X-Forwarded-For / X-Forwarded-Proto / X-Forwarded-Host headers are believed. Empty means the direct peer is always treated as the client. It decides the client address the rate limiter counts, the session cookie's Secure flag, HSTS and the CORS same-origin check.
TINA4_ALLOW_PRIVATE_REQUESTS
(off)
Server-Side Request Forgery (SSRF) opt-out. Off by default, so outbound fetches to private, loopback and link-local addresses are refused. Set truthy only in a trusted internal deployment.
Setting it switches the global limiter on at boot: maximum requests per window per client address. false, 0, no or off switches every limiter off. Any other value that isn't a positive whole number stops the boot with Tina4::RateLimitConfigError. Health and readiness probes are never counted. Counts are per process.
TINA4_RATE_WINDOW
60
Rate-limit window in seconds. A value that isn't a positive whole number stops the boot.
Session lifetime in seconds. 0 never expires, with a cookie that lasts for the browser session. A value that isn't a whole number of zero or more uses 3600 with one warning.
Session cookie name. Used unless the caller passes an explicit cookie_name. A value that isn't a valid HTTP token is ignored, with one logged error, and tina4_session is used.
TINA4_SESSION_HTTPONLY
true
Sets the HttpOnly attribute on the session cookie. Set false to allow JavaScript access.
TINA4_SESSION_SECURE
false
Always sets the Secure attribute on the session cookie. Without it, the flag follows the request's scheme, and a proxy's X-Forwarded-Proto counts only from TINA4_TRUSTED_PROXIES. Set it behind a TLS proxy you can't list.
Response cache backend. Options: memory, file, redis, valkey, memcached, mongodb, database. Falls back to file if the configured backend is unreachable.
TINA4_CACHE_DIR
data/cache
Cache directory for the file backend.
TINA4_CACHE_TTL
0
Default cache TTL in seconds (0 disables caching for the global instance; the singleton helper uses 60 when unset).
TINA4_CACHE_MAX_ENTRIES
1000
Maximum cache entries before eviction.
TINA4_CACHE_URL
redis://localhost:6379
Connection URL for remote cache backends. For database, falls back to TINA4_DATABASE_URL when unset.
TINA4_CACHE_USERNAME
(none)
Username for the cache backend. May also be embedded in TINA4_CACHE_URL.
TINA4_CACHE_PASSWORD
(none)
Password for the cache backend. May also be embedded in TINA4_CACHE_URL (e.g. redis://:pass@host). Memcached is unauthenticated.
When true, the GraphQL module auto-generates a schema from registered ORM models. Set false to require an explicit schema.
TINA4_GRAPHQL_ENDPOINT
/graphql
Path the GraphQL handler is mounted at when the caller doesn't pass an explicit path.
TINA4_GRAPHQL_MAX_NODES
1000
Maximum nodes a single query may request before the handler rejects it. Caps query cost against a deeply nested or aliased request. Set 0 to disable the limit.
Comma-separated broker list (e.g. localhost:9092).
TINA4_KAFKA_GROUP_ID
tina4_consumer_group
Kafka consumer group ID.
TINA4_KAFKA_AUTO_OFFSET_RESET
earliest
Where a NEW Kafka consumer group (no committed offset) starts: earliest (replay the backlog) or latest (skip it). Falls back to the bare KAFKA_AUTO_OFFSET_RESET.
Open WebSocket connections a server holds. The next upgrade is answered 503 Service Unavailable before the handshake; a closed connection frees its slot.
TINA4_WS_MAX_FRAME_SIZE
1048576
Largest WebSocket frame payload a server accepts, in bytes (1 MiB). A frame declaring more is refused on its header: a warning is logged and that connection is closed.
SMTP encryption. tls and starttls upgrade with STARTTLS and fail if the server doesn't offer it; ssl (or port 465) is implicit TLS; none is plain. Certificates are always verified.
TINA4_MAIL_IMAP_HOST
(inherits mail host)
IMAP server for inbound mail.
TINA4_MAIL_IMAP_PORT
993
IMAP server port.
TINA4_MAIL_IMAP_USERNAME
(inherits SMTP username)
IMAP authentication username. Mapped from legacy IMAP_USER.
TINA4_MAIL_IMAP_PASSWORD
(inherits SMTP password)
IMAP authentication password. Mapped from legacy IMAP_PASS.
TINA4_MAIL_IMAP_ENCRYPTION
tls
IMAP encryption. tls (or ssl) is implicit TLS, starttls upgrades a plain connection before login, none is plain. Certificates are always verified.
TINA4_MAIL_CAPTURE
false
Force local DevMailbox capture and skip SMTP, even when an SMTP host exists. A missing host also captures.
TINA4_MAIL_REDIRECT_TO
(none)
Comma-separated safety recipients for real SMTP delivery. Replaces To, Cc, and Bcc.
TINA4_MAILBOX_DIR
data/mailbox
Storage directory for captured mail. This setting does not enable or disable capture.
TINA4_DEBUG does not suppress email. On staging, set TINA4_MAIL_CAPTURE=true to keep every message local, or set TINA4_MAIL_REDIRECT_TO=qa@example.com,product@example.com to exercise SMTP without reaching original recipients. Capture takes precedence when both are set.
TINA4_MAIL_HOST, TINA4_MAIL_PORT, TINA4_MAIL_USERNAME, TINA4_MAIL_PASSWORD, TINA4_MAIL_FROM, TINA4_MAIL_FROM_NAME, TINA4_MAIL_IMAP_HOST, TINA4_MAIL_IMAP_PORT are accepted as legacy aliases. New projects should use the TINA4_MAIL_* names.
Console log level. Options: [TINA4_LOG_ALL], [TINA4_LOG_DEBUG], [TINA4_LOG_INFO], [TINA4_LOG_WARNING], [TINA4_LOG_ERROR], [TINA4_LOG_NONE]. Also accepts plain DEBUG, INFO, ERROR, etc.
TINA4_LOG_MAX_SIZE
10
Per-file log size limit in megabytes. Rotated when exceeded.
TINA4_LOG_KEEP
5
Number of rotated log files to retain.
Logs default to stdout. Set TINA4_LOG_OUTPUT=file plus TINA4_LOG_FILE=app.log to write to disk; Ruby's stdlib Logger rotates at TINA4_LOG_ROTATE_SIZE bytes and keeps TINA4_LOG_ROTATE_KEEP backups natively.
Variable
Default
Description
TINA4_LOG_FILE
(empty = stdout only)
Explicit log file path. Absolute, or resolved relative to TINA4_LOG_DIR.
TINA4_LOG_DIR
logs
Directory used when TINA4_LOG_FILE is set without an absolute path.
TINA4_LOG_FORMAT
text
Log line format. Accepts text or json.
TINA4_LOG_OUTPUT
stdout
Output sink. Accepts stdout, file, or both.
TINA4_LOG_CRITICAL
false
When true, gates the new critical level and raises on log write failures instead of swallowing them.
TINA4_LOG_ROTATE_SIZE
10485760
Per-file rotation threshold in bytes (10 MB). 0 disables rotation. Handled natively by stdlib Logger.new(path, shift_age, shift_size).
The app-facing Ai client and the developer dashboard share the TINA4_AI_* namespace. The client supports local OpenAI-compatible servers, OpenAI, and Anthropic. See Chapter 39: AI Client for code examples.
Variable
Default
Description
TINA4_AI_PROVIDER
local
Provider used by the app-facing client: local, openai, or anthropic.
TINA4_AI_URL
Provider-specific
Base URL or full endpoint. Local defaults to http://localhost:11437; OpenAI and Anthropic use their public API bases.
TINA4_AI_MODEL
Provider-specific
Default model. Local uses llama3.2, OpenAI uses gpt-4o-mini, and Anthropic uses claude-3-5-haiku-latest.
TINA4_AI_KEY
(none)
Required before an OpenAI or Anthropic request. Local requests need no key.
TINA4_AI_TIMEOUT
60
Total request deadline in seconds, including retries and response reads.
TINA4_AI_CONNECT_TIMEOUT
10
Connection-establishment deadline in seconds.
TINA4_AI_MAX_RETRIES
2
Retries before output for connection failures, HTTP 429, and HTTP 5xx.
TINA4_EMBED_URL
(inherits TINA4_AI_URL)
Optional embedding base URL or full endpoint.
TINA4_RAG_URL
http://localhost:11438
RAG service used by the developer dashboard.
TINA4_VISION_URL
http://localhost:11437/api/chat
Vision endpoint used by developer tools, not the app-facing AI client.
TINA4_IMAGE_URL
http://localhost:11437/api/generate
Image endpoint used by developer tools, not the app-facing AI client.
TINA4_SUPERVISOR_URL
http://localhost:9999
Rust supervisor URL used by developer tools.
TINA4_MCP_REMOTE
false
Allows MCP to bind beyond localhost. Do not enable it on a public production interface.
TINA4_NO_AI_PORT
false
Disables the developer AI port listener.
TINA4_OVERRIDE_CLIENT
false
Lets the framework start without the Rust client in containers and CI.
The tables above list every knob. These are the setups most apps actually reach for, ready to paste into .env. Each block sets only what the feature needs. Everything else keeps its default.
One URL points the ORM, the migrations, and the query builder at Postgres. Credentials can ride in the URL or sit in their own variables, which keeps the password out of your shell history.
The response cache and the cross-request query cache both speak to the same Redis. Point them at it and every instance shares one cache, invalidated globally on every write.
The file backend is fine for a single server. Move sessions to Redis the moment you run more than one instance, so a user stays logged in whichever instance answers the next request.
The dashboard AI talks to a local model through Ollama by default, so nothing leaves your machine. Point the URLs elsewhere only when you run the hosted Tina4 AI services.
Debug mode lights up the Swagger UI, the dev dashboard, detailed error pages, and live reload. Keeping the browser flag on stops a new tab opening every time you save a file.
No TINA4_DEBUG. It defaults to false, which is what you want in production. Set a real secret, a real database, locked-down CORS origins, HSTS, and SMTP credentials if you send email. Everything else has a production-appropriate default.