TermlessDocs

Guides

Running the server

Installing termlessd on Linux as a system service, its settings, running it behind a proxy, the data folder, adding an account, upgrading, the doctor, and reading diagnostics, the trails, crash reports and undecoded frames.

termlessd is one static binary (about 14 MB, musl, no dependencies) for x86_64 and aarch64 Linux. It needs a data folder it owns and a port to listen on; everything else is optional. This page installs it as a systemd service; to run it as a container instead, see Running in Docker.

Install#

Releases come as one archive per processor: termless-<version>-linux-x86_64.tar.gz for most PCs and cloud servers, termless-<version>-linux-aarch64.tar.gz for ARM machines (Ampere and Graviton servers, a 64-bit Raspberry Pi). uname -m on the box tells you which (arm64 is aarch64). Each archive holds one folder with the server, install.sh, termlessd.service, the Docker files and a README. On the box:

curl
tar xzf termless-<version>-linux-x86_64.tar.gz
cd termless-<version>-linux-x86_64
sudo sh install.sh

The script creates the system user termless, installs the binary to /usr/local/bin/termlessd, installs and enables the hardened systemd unit (own user, ProtectSystem=strict, a 512 MB memory cap, no capabilities), and starts it with its data in /var/lib/termless, listening on 127.0.0.1:8780. Running it again upgrades in place and restarts the service.

curl
sudo cat /var/lib/termless/setup-token     # the one-time setup token, on a first run
journalctl -u termlessd -n 50               # the log
curl -s http://127.0.0.1:8780/api/v1/health    # "version" is null without a key, so the version stays private

Reaching it#

The service listens on localhost only. Reach the dashboard over an SSH tunnel (ssh -N -L 8780:127.0.0.1:8780 you@your-box, then http://127.0.0.1:8780), or put it on your own domain with Caddy, nginx, a Cloudflare Tunnel or Tailscale (Your own domain). Never open the port itself to the internet: API keys and the password would travel unencrypted, and a caller could pick its own address.

The ways to reach it from elsewhere (a tunnel, a VPN, a proxy) and what each one costs: Remote access.

Behind a reverse proxy#

Start with --trust-proxy (TERMLESS_TRUST_PROXY=1) so lockouts and the Secure cookie flag use the real client address and scheme. The server then reads the client IP from one header, --proxy-header / TERMLESS_PROXY_HEADER (default X-Forwarded-For, its last hop; X-Real-IP is never a fallback), and https from X-Forwarded-Proto. Two rules, both yours: the proxy must set or overwrite that header on every request it forwards, and nothing but the proxy may reach termlessd's port (keep --listen 127.0.0.1:8780). Otherwise a client picks its own address and the lockouts protect nothing. Without --trust-proxy every such header is ignored.

Caddyfile
termless.example.com {
    reverse_proxy 127.0.0.1:8780 {
        header_up X-Forwarded-For {remote_host}
    }
}

header_up replaces whatever the caller sent with the address Caddy sees, and Caddy sets X-Forwarded-Proto itself. To use X-Real-IP instead, write header_up X-Real-IP {remote_host} and start termlessd with --proxy-header X-Real-IP. nginx, a Cloudflare Tunnel and the checks that prove it works: Your own domain.

First run#

With no admin password set, the server prints a one-time setup token to its log and writes it to <data>/setup-token (sudo cat /var/lib/termless/setup-token). Open the dashboard; it asks for the token and a new password (15 to 200 characters with a lowercase letter, a capital, a digit and a symbol). Do this before you put the server on a domain: until then, whoever holds the token sets the password. Or set TERMLESS_ADMIN_PASSWORD in the service's environment before the first start to skip that step. sudo sh install.sh --password (or termlessd passwd) sets a new password later, from the box, and signs every dashboard session out.

Settings#

Each setting is a flag or an environment variable; the flag wins.

FlagVariableDefaultWhat
--data DIRTERMLESS_DATA~/.local/share/termless (/var/lib/termless under systemd)The data folder.
--listen ADDRTERMLESS_LISTEN127.0.0.1:8780Address and port.
--trust-proxyTERMLESS_TRUST_PROXY=1offTake the client IP from the proxy header and https from X-Forwarded-Proto. Only behind a proxy you control that overwrites that header.
--proxy-header HTERMLESS_PROXY_HEADERX-Forwarded-ForThe one header carrying the client IP when --trust-proxy is on (last hop). X-Real-IP is never a fallback.
--trusted-proxies LISTTERMLESS_TRUSTED_PROXIES127.0.0.0/8,::1Where the proxy's connection comes from, as CIDRs. Forwarding headers from any other peer are ignored, even with --trust-proxy. Set it when the proxy runs on another machine or in a container.
--cookie-secureTERMLESS_COOKIE_SECURE=1off (on when the request is https)Always mark the session cookie Secure.
--web-dir DIRTERMLESS_WEBbuilt inServe the dashboard and docs from a folder instead of the embedded copy, for editing them.
TERMLESS_LOGinfoLog filter, for example info,termless=debug.
TERMLESS_THREADS2Async worker threads. Two carry 400,000 ticks a second to 200 clients at under 60 % of a core; raise it only for a measured reason (docs/architecture.md in the repository explains why more is slower).
TERMLESS_REQUEST_TIMEOUT30Seconds before a request (other than a stream) is given up with 504. 0 removes the bound.
TERMLESS_BROKER_TIMEOUT_MS20000Milliseconds one call to the broker may take before it is 504 timeout (1,000 to 120,000). A call that is never answered closes the broker link after three times this, so no late reply is taken for another call's.
TERMLESS_TRADE_RESULT_TIMEOUT_MS25000Milliseconds a trade waits for its final result once the broker took it (1,000 to 25,000, so the trade answers itself inside the 30 s request bound). Without one it is 504 unconfirmed; a result that comes later, within 120 s, still settles its Idempotency-Key.
TERMLESS_CATCH_UP_RETRY_S60,120,300,600,900Seconds to wait before reading again the deals made during a gap when the broker's history did not answer the last read; the last value repeats.
TERMLESS_TICK_HISTORY1000Ticks kept per streaming symbol for GET /ticks, at most 100000; 0 keeps none. An account keeps at most 100,000 over all its symbols together, whatever this says.
TERMLESS_ADMIN_PASSWORDSets the admin password on the first start only.
TERMLESS_ALLOW_PRIVATE_GATEWAYS=1offLets an account's gateway resolve to a loopback, link-local, private or carrier-grade NAT address. Refused with 400 otherwise.
TERMLESS_ALLOW_INSECURE_GATEWAYS=1offLets an account use a plain ws:// host (the fake broker used in tests); implies the private-gateways setting. Never in production.
TERMLESS_TEST_PANIC_ROUTE=1offAdds GET /api/v1/test/panic, which panics, so the tests can check what a panic is answered with (0.7.1). It writes a crash report like any panic. Never in production.

Commands: termlessd serve (the default), termlessd passwd, termlessd doctor (below), termlessd crash-test --data /tmp/x (panics on purpose to prove crash reports work on this box; give it a throwaway --data, since a report in the live data folder makes /status say degraded for 24 hours), termlessd --version.

The doctor#

termlessd doctor [--data DIR] checks a box and prints one report with a verdict (ok, warnings or problems; exit code 0, 1 or 2). It works offline, before or beside a running server, and GET /api/v1/diagnostics/doctor (admin) runs the same checks against the live server and returns them as JSON.

curl
termlessd doctor --data /var/lib/termless
Text
termlessd 0.1.0 doctor: warnings
  data folder: /var/lib/termless
  ok    data folder   /var/lib/termless exists and is writable
  ok    master.key    /var/lib/termless/master.key present (owner-only)
  ok    database      /var/lib/termless/termless.db (132 KB) integrity ok; rows: accounts 1, keys 2, audit 4821, account_events 310, equity_samples 1440
  ok    listen        serving on http://127.0.0.1:8780
  ok    gateway       pepperstone-12345678: mt5-demo01.pepperstone.com:443 is Pepperstone Group Limited build 6090 (2 servers); connected, build 6090
  WARN  clock         7 s off the broker's clock
                      fix: enable NTP (timedatectl set-ntp true); candle times and expirations depend on it
  ok    disk          18240 MB free; termless uses 3 MB
CheckWhat it looks at
data folderExists, is writable, is owner-only (mode 0700).
master.key, setup-tokenPresent and owner-only; the token only until setup is done.
databaseOpens, passes PRAGMA integrity_check, with row counts per table. A running server holds the lock; the doctor says so rather than failing.
listenThe address is serving, free, or cannot be bound.
gateway (one per account)DNS, then TLS and the web terminal page with its build (or a TCP connect for a plain ws:// test gateway), plus the session's live state when the server is running.
clockThe box against the first connected broker; warns past 5 s, because candle times and expirations depend on it.
diskFree space and what termless uses; fails under 200 MB, warns under 1 GB.

Every warn and fail carries a fix: what to do, in one line. Startup errors do the same: a port in use, an unwritable data folder and a damaged master.key each name the fix.

The data folder#

Created with mode 0700; every file inside is owner-only.

PathWhatBack up?
termless.dbSQLite: settings, accounts (passwords sealed with AES-256-GCM), keys (hashes only), sessions, the server directory, the trails (audit, connection events, equity samples, idempotency results), the magic numbers and long comments kept for orders, and each account's newest 1,024 trade events (so their numbering carries on across a restart).Yes.
master.keyThe key that seals account passwords. Losing it makes every stored MT5 password unreadable: you would add the accounts again.Yes, separately from the database.
setup-tokenThe one-time token, present until setup is done.No.
termlessd.pidWritten at start, removed at a clean exit. Present at start = the last run ended uncleanly, and a report is written.No.
termlessd.lockHeld locked while termlessd runs (0.6.3): a second termlessd started on the same folder is refused before it touches anything, with a message naming the folder and the live pid.No.
logs/termlessd.<date>.logOne log file per day, 14 kept.As you like.
crashes/Crash reports, one text file per panic or unclean exit.For a bug report.
captures/undecoded.jsonlFrames from the broker the client could not decode (below).For a bug report.

Adding an account#

In the dashboard, Accounts > Add account: pick the server, enter the login and password, choose the symbols to keep streaming. The directory has 57 servers built in, from these brokers: MetaQuotes (demo), Pepperstone, Fusion Markets, IC Markets, Exness (and its Expert Execution servers), Admirals, BlackBull Markets, Deriv, Key to Markets, Fxview, Errante, Axi, Octa, OANDA, FBS (Tradestone), PU Prime, Headway and Taurex; prop firms: FTMO, The5ers, E8 Markets, FundingPips, FundedNext, Maven, Audacity, Funded Trading Plus, AquaFunded, FXIFY, BrightFunded, OANDA Prop Trader and For Traders. Search it by broker, server name or host; spaces, dashes and dots don't matter. For any other broker, Check a host with its web terminal's host reads that page and adds its servers (Find your server shows where to find the server name and that address). Or over the API:

curl
curl -s -X POST "$TERMLESS_URL/api/v1/accounts" -b cookies.txt -H "Content-Type: application/json" \
  -d '{"label": "Pepperstone demo", "login": 12345678, "password": "your MT5 password",
       "server": "Pepperstone-Demo", "symbols": ["XAUUSD", "EURUSD"]}'

The account connects in the background; poll GET /api/v1/accounts/{id} until status.connected is true. A refused login shows as status.login_rejected: true with last_error, and the account then retries only every five minutes so a wrong password cannot get it locked at the broker. Fix it with PATCH /api/v1/accounts/{id} and a new password. A login refused within a minute of losing a working connection is different: brokers refuse logins for a few seconds while their server restarts (often at weekends), so that one is tried again after 10, 20, 30 and 60 seconds before the five-minute wait.

Brokers must have web access turned on for the server (the same thing that lets their web terminal work). The host you connect to decides which trade servers you can reach; POST /api/v1/servers/check with a host reports its company, build and servers. Gateways must be on the public internet: a host that resolves to a loopback, link-local, private or carrier-grade NAT address is refused with 400 (by the check and when adding or changing an account) unless the server runs with TERMLESS_ALLOW_PRIVATE_GATEWAYS=1. A failed check answers one generic 502; the reason is in the log and in the audit trail (kind: "server_check").

Brokers with broken certificates#

Termless always checks a broker's certificate, the way a browser does, and never turns that check off. Some brokers set theirs up badly; three cases are handled:

  • The broker leaves out a certificate in the middle (IC Markets does). Browsers fetch the missing one from the address written in the broker's certificate; Termless does the same (only from a public address, at most 16 KB, then the whole chain must still lead to a trusted authority), keeps it in memory, and ships the one IC Markets needs in case the fetch is blocked. Nothing to do; the log says once that the broker's chain is incomplete.
  • The address is a bare IP (Exness's servers). Add the name on its certificate as tls_name (the directory already knows Exness's: exwebterm.com); Termless connects to the IP and checks the certificate for that name.
  • The certificate is for another name, or from a private authority (Alpari, mt5.deriv.com, Blueberry Funded). Check a host answers untrusted_certificate and shows the certificate: its names, who issued it, when it expires, and its key fingerprint (spki_sha256). If you are sure it is the broker's real address, pin that key: check again with fingerprint set to it (or POST /api/v1/servers/{server}/trust). From then on that host is accepted with that key only, and refused with certificate_changed if the key ever changes; DELETE the trust to undo it. Pins and unpins are in the audit trail.

A broker whose web terminal only lets browsers in (a Cloudflare challenge, as FxPro and AvaTrade do) answers browser_only: Termless cannot reach it, and pinning does not change that.

Upgrading#

Your accounts, keys, settings and history live in /var/lib/termless, never in the release folder, so an upgrade only swaps the program. Unpack the new release anywhere and run its installer:

curl
tar xzf termless-<new version>-linux-x86_64.tar.gz
cd termless-<new version>-linux-x86_64
sudo sh install.sh
What it prints
upgrading: termlessd 0.1.0 (x86_64-unknown-linux-musl) -> termlessd 0.2.0 (x86_64-unknown-linux-musl)
data backed up to /var/lib/termless/backups/20261007-174512
running: termlessd 0.2.0 (x86_64-unknown-linux-musl)

Step by step, the installer:

  1. stops the service, so nothing writes to the data while it is copied;
  2. copies termless.db and master.key to /var/lib/termless/backups/<time>/ (the three newest copies are kept);
  3. keeps the running program as /usr/local/bin/termlessd.previous;
  4. installs the new program and unit file (your drop-ins from systemctl edit termlessd stay; never edit termlessd.service itself, the next upgrade replaces it);
  5. starts it and waits up to 20 seconds for it to listen. The database is upgraded in place on start. If it does not come up, the installer prints the last log lines and stops there.

Each account logs out cleanly and is connected again a few seconds after the new version starts (3.5 to 7 seconds from start to connected, measured on a small server against IC Markets), and open streams end with reason: "server stopping" so clients reconnect. Trade events keep their numbering across the upgrade; the deals made while the server was down come to streaming clients marked caught_up (Streaming).

To go back to the version before, with the data exactly as it was before the upgrade: sudo sh install.sh --rollback (from any release folder). Anything written since the upgrade (new keys, trails) is lost by going back; trades themselves live at the broker.

Diagnostics#

GET /api/v1/diagnostics (admin) is one snapshot of what the server knows about itself, and the dashboard's Health page shows the same on its Troubleshoot tab (the Diagnostics page before 0.5.1), refreshed every five seconds.

PartTells you
version, target, pid, started_at, uptime_sWhich build is running and for how long.
process.rss_kb, threads, open_filesMemory and handles, from /proc (null off Linux). 14 MB idle with one account is normal.
data_dir, log_file, db_bytesWhere things are and how big the database is.
dashboard_sessions, streams.sse, streams.wsWho is connected.
accounts[]Each account's status plus ticks_seen, last_tick_at_ms, last_frame_at_ms, streams, ticks_coalesced (dropped for a slow stream reader) and undecoded. A connected account with an old last_frame_at_ms is about to be declared dead.
undecoded.total, by_command[], recent[]Frames the client could not decode, counted per account, command and kind since this start; recent also holds the ones kept before a restart.
problems[]The last 100 warnings and errors from the log, newest first. The first place to look.
crashes[], unclean_exit_reportCrash reports on disk, and the file name (such as unclean-exit-2026-10-03T00-12-07Z.txt) of the report written at this start if the previous run died, else null. It stays set for the whole run; read it with /diagnostics/crashes/{name}.

Four more routes give the detail: GET /api/v1/diagnostics/doctor (the checks above), GET /api/v1/diagnostics/logs?lines=500 (the end of today's log), GET /api/v1/diagnostics/crashes/{name} (one report) and GET /api/v1/diagnostics/undecoded?account=&limit=&bodies=1 (frames with their bytes; without bodies=1 each body_hex is cut to 128 bytes and body_preview: true says so).

The trails#

Every write and every security event is recorded in the audit table with the request id that caused it; each account's connection history and an equity curve sit beside it. Rows are written off the request path by a batch writer, so a trade never waits for SQLite, and pruned hourly: audit 90 days or 200,000 rows, connection events 90 days or 50,000 rows, equity 7 days, idempotency results 24 hours. The activity and trails page explains how to read them over the API; from the box itself:

curl
sqlite3 /var/lib/termless/termless.db \
  'select at, kind, actor, route, summary, status, retcode, latency_ms, request_id from audit order by id desc limit 50'
grep 'id=7c1e2a9f4b3d8e60' /var/lib/termless/logs/termlessd.2026-10-03.log   # the log lines of one request

Crash reports#

A panic inside one request does not take the server down (the server build unwinds), but it does write crashes/<time>-panic.txt: the message, the thread, a backtrace with function names (the binary keeps its symbol table for this), the accounts and their builds at the time, and the last log lines. An exit without a clean shutdown (a kill, a power loss) is noticed at the next start through termlessd.pid and written as crashes/<time>-unclean-exit.txt; unclean_exit_report in diagnostics names it. termlessd crash-test --data /tmp/x proves the mechanism works on a new box.

Undecoded frames#

The MT5 web protocol differs slightly between broker builds (5830, 6090, 6231 have been seen). When a frame or a message body does not parse, or a push arrives with a command id the client does not handle, the client keeps going and records it: 200 in memory, at most 5 bodies an hour per (account, command, kind) appended to captures/undecoded.jsonl, the rest only counted. At start the newest records of that file (its last 4 MB) are read back, so a restart does not empty the list. A new broker build first shows up here. kind tells you how deep the trouble is: frame (the outer frame or its encryption did not check out), body (a known command whose body did not parse) or unknown_push (a command the client has no decoder for). Since 0.6.0 a fourth kind, extra, is a reply read in full with bytes after the records Termless knows (a newer build may have added a field; both brokers seen so far send 12 bytes a position after the positions): nothing was lost, so it is listed here but never counted as undecoded, in /status, /ready or the metrics. Command 25, a short notice at the daily session break, is a known push since 0.2.2: it is not decoded (nothing depends on it) and no longer shows up here or in a daily log line.

Logs#

stdout (so journalctl -u termlessd) and logs/termlessd.<date>.log, one file per day, 14 kept. TERMLESS_LOG=info,termless=debug turns on protocol-level detail for the client crate; termlessd=debug for the API. Every API request is logged with its status, duration and request id (req{id=...} on every line it wrote; the query string is left out because it can hold a key).

Checking a box end to end#

The devtools/e2e.py script in the repository runs about 90 checks against a running server (health, setup, keys, every market route, margin, order checks, streams, and with --trade SYMBOL a real round trip of a 0.01 lot trade on the demo):

curl
python3 e2e.py --base http://127.0.0.1:8780 --password '...' --trade BTCUSD

Markets matter for a check: forex and gold close Friday about 21:00 UTC, and Pepperstone's crypto pauses daily from 23:55 to 00:01 broker time, so a check then sees no ticks.