This guide covers running LDK Server in production: process management, backups, security, monitoring, and remote access.
LDK Server integrates with systemd via sd_notify. It sends READY=1 after the gRPC listener
is bound and STOPPING=1 when shutting down. A sample unit file can be found in
contrib/ldk-server.service.
The server handles SIGTERM and CTRL-C (SIGINT). On receipt, it:
- Signals all active streaming clients (SubscribeEvents) to disconnect
- Stops the LDK Node (persists channel state)
- Exits cleanly
Important: LDK Server does not rotate or truncate its own log file. Without log rotation configured, the log file will grow indefinitely and can eventually fill your disk. A full disk can prevent the node from persisting channel state, risking fund loss.
The server reopens its log file on SIGHUP. This integrates with standard logrotate. Save
the following config to /etc/logrotate.d/ldk-server (adjust the log path to match your
setup):
/var/lib/ldk-server/regtest/ldk-server.log {
daily
rotate 14
compress
missingok
notifempty
postrotate
systemctl kill --signal=HUP ldk-server.service
endscript
}
| File | Priority | Description |
|---|---|---|
<storage_dir>/keys_seed |
Critical | Node identity and master secret. Required to recover on-chain funds. |
<network_dir>/ldk_node_data.sqlite |
Critical | Channel state and on-chain wallet data. Required to recover channel funds. |
<network_dir>/ldk_server_data.sqlite |
Nice-to-have | Payment and forwarding history |
- Network graph data (re-synced from gossip or RGS)
- Fee rate cache (re-fetched from the chain backend)
- The API key (can be regenerated, but clients will need the new one)
- The TLS certificate (can be regenerated, but clients will need the new one)
Warning: Do not restore a backup onto two running nodes simultaneously. Running the same node identity on two instances will cause channel state conflicts and potential fund loss.
- Auto-generated as 32 random bytes on first startup
- Stored at
<network_dir>/api_keywith0400permissions (read-only for owner) - The hex-encoded form of this key is used for HMAC authentication
- Treat it as a secret: anyone with the API key and network access to the gRPC port can control the node
- Self-signed ECDSA P-256 certificate generated automatically
- Private key stored at
<storage_dir>/tls.keywith0400permissions - Certificate includes
localhostand127.0.0.1in SANs by default - Add your server's hostname/IP to
[tls] hostsfor remote access
The gRPC service binds to 127.0.0.1:3536 by default. For remote access, either:
- Change
grpc_service_addressto bind to0.0.0.0:3536and add the server's hostname to[tls] hosts, or - Use a reverse proxy (e.g., nginx, Caddy) that terminates TLS and forwards to the loopback address
LDK Server can expose metrics in Prometheus text format. Prometheus is an open-source monitoring toolkit that scrapes HTTP endpoints and stores time-series data for alerting and dashboards.
Enable metrics in the config:
[metrics]
enabled = true
poll_metrics_interval = 60Metrics are served at GET /metrics on the same port as the gRPC service (default 3536).
This is a plain HTTP endpoint (not gRPC), returning Prometheus text format.
Basic Auth is recommended to prevent unauthorized access to node metrics:
[metrics]
enabled = true
username = "prometheus"
password = "secret"The Prometheus scrape config would then use:
scrape_configs:
- job_name: ldk-server
scheme: https
tls_config:
ca_file: /path/to/tls.crt
basic_auth:
username: prometheus
password: secret
static_configs:
- targets: [ 'localhost:3536' ]Metrics cover:
- On-chain and Lightning balances
- Public and Private Channel counts
- Payment counts (successful, failed, pending)
- Peer count
To allow clients to connect from other machines:
- Update TLS hosts: Add the server's hostname or IP to
[tls] hostsin the config so the certificate's SANs cover the address clients will use. - Update bind address: Set
grpc_service_addressto bind on the appropriate interface (e.g.,0.0.0.0:3536). - Distribute the TLS certificate: Copy
<storage_dir>/tls.crtto each client machine. Clients must pin this certificate since it is self-signed. - Share the API key: Provide the hex-encoded API key to authorized clients.
If you regenerate the TLS certificate (by deleting tls.crt and tls.key and restarting),
all clients will need the new certificate.
Data is stored in per-network subdirectories (bitcoin/, testnet/, signet/, regtest/,
etc.) under the storage root. This means you can run multiple networks from one storage
directory without conflicts.
The keys_seed file is shared across networks (stored at the storage root, not per-network).
Keys are split by network at the derivation path level, so the same seed will produce
different keys.