A self-custodial Lightning node with a management UI and wallet/API layer, deployed
on Railway. This guide walks all four phases. Read CLAUDE.md for the "why" and the
Railway-specific gotchas.
Heads-up: this exact LND stack is the most involved thing to run on Railway. If it gets painful,
phoenixd + LNbitsis a much simpler Railway-native alternative (self-custodial, auto liquidity, no port 9735, no cert/macaroon sharing).
- A Railway account and a GitHub account.
curlon your own computer (for Phase 1 wallet creation).- Somewhere safe to write down 24 words (paper, metal backup).
- Update image tags to current stable before deploying:
- LND: https://github.com/lightningnetwork/lnd/releases
- ThunderHub:
apotdevin/thunderhub - LNbits:
lnbits/lnbits
Put the lnd/ folder contents (Dockerfile, lnd.conf, start.sh) into a repo,
or point Railway at this repo's lnd/ directory. Edit lnd.conf -> set alias.
- New project -> Deploy from GitHub repo.
- Naming the service
lnddoes not guarantee its private address islnd.railway.internal— Railway locksRAILWAY_PRIVATE_DOMAINto the service's slug at creation time and does not update it on rename. After creating the service, check its actualRAILWAY_PRIVATE_DOMAINand settlsextradomaininlnd.confto match that value exactly. See DEPLOY.md. - Add a Volume, mount path
/data. - Deploy. In the logs LND will start and WAIT ("waiting for wallet") - expected.
LND REST is HTTPS with a self-signed cert, so use a TCP Proxy (raw passthrough),
NOT the HTTP domain. In the lnd service networking settings, add a TCP Proxy for
port 8080. Note the host:port Railway gives you (e.g. x.proxy.rlwy.net:23456).
Edit scripts/create-wallet.sh (set PROXY + password), then:
./scripts/create-wallet.sh genseed # prints 24 words -> WRITE THEM DOWN
# paste the 24 words into SEED_WORDS in the script, then:
./scripts/create-wallet.sh initwallet # creates + unlocks the wallet
Or do it by hand:
curl -k https://PROXY_HOST:PORT/v1/genseed
curl -k -X POST https://PROXY_HOST:PORT/v1/initwallet \
-d '{"wallet_password":"BASE64_PW","cipher_seed_mnemonic":["w1",...,"w24"]}'
(BASE64_PW = echo -n "your-password" | base64)
Watch the logs until LND reports synced to chain (minutes to ~1 hour).
- Add Railway env var
WALLET_PASSWORD= your plain wallet password. - Uncomment in
lnd.conf:wallet-unlock-password-file=/data/walletpassword.txt - Commit + redeploy.
start.shwrites the password file on boot and LND auto-unlocks.
Checkpoint: LND deployed, wallet created, SEED SAVED, synced, auto-unlock on.
- Set Railway env var
PRINT_CREDS=1on thelndservice, redeploy. - Open the logs and copy:
- ADMIN MACAROON (hex)
- TLS CERT (base64)
- Remove
PRINT_CREDSand redeploy (don't leave creds printing to logs).
- In
thunderhub/thubConfig.yaml, setmasterPassword, and paste themacaroon(hex) andcertificate(base64). - Push
thunderhub/to a repo (or this repo'sthunderhub/dir). - New Railway service from that repo. It talks to the
lndservice'sRAILWAY_PRIVATE_DOMAINon port10009over the private network — see the note in Phase 1 above about that value not always beinglnd.railway.internal. - Give it a public domain (ThunderHub listens on port 3000). Log in with your masterPassword.
- New Railway service from image
lnbits/lnbits:latest. - Add a Volume at
/app/data. - Add env vars from
lnbits/.env.example, pasting:LND_REST_MACAROON= ADMIN MACAROON (hex)LND_REST_CERT= TLS CERT (hex)
- Give it a public domain (LNbits listens on
$PORT, which Railway provides).
Open the LNbits URL, create a wallet, and check it shows your node's balance once you have funds. (See MIGRATION.md if you are restoring LNbits data from Voltage.)
- Add a TCP Proxy for port 9735 on the
lndservice. - Add the proxy host:port to LND as an external address (add
externalip=PROXY_HOST:PORTtolnd.conf, redeploy). This lets peers reach you.
- Remove the temporary REST (8080) TCP proxy if you no longer need external REST.
- Never expose gRPC/REST publicly without need. Protect the UIs.
- In ThunderHub, get an on-chain address, send BTC, wait for confirmation.
- Open channels (batch-open several in one tx to save on fees). Check mempool.space and open when fee rates are low.
Three always-on services on Railway's usage billing typically run ~$10-20/month, more than a flat $5 VPS. You're paying for the platform convenience.
- 24-word seed = primary backup (offline).
- Also keep LND's
channel.backup(Static Channel Backup) - ThunderHub can export it. It lets you recover channel funds if the deployment dies.