Warning: Tor support in LDK Server applies only when connecting outbound to
.onionLightning peers. Connections to clearnet peers are not routed through Tor exit nodes. All other connections, including Electrum servers, Esplora endpoints, and Rapid Gossip Sync (RGS) servers, are also not routed through Tor and will use your normal network connection. If you require full network privacy, you should use a local bitcoind node as your chain source. Support for routing these connections through Tor may be added in the future.
LDK Server supports connecting to peers over Tor. This guide covers both outbound connections
(connecting to .onion peers) and inbound connections (making your node reachable as a hidden
service).
Follow tor's official installation instructions for your platform: https://support.torproject.org/little-t-tor/getting-started/installing/
The Tor daemon listens on 127.0.0.1:9050 by default.
The [tor] section in the config sets a SOCKS proxy for outbound connections to OnionV3 peers:
[tor]
proxy_address = "127.0.0.1:9050"This requires a running Tor daemon with a SOCKS port. Only connections to .onion peers use
the proxy. Connections to IPv4/IPv6 peers, Electrum servers, and Esplora endpoints are not
routed through Tor.
To make your node reachable as a Tor hidden service, you need to configure Tor itself. LDK Server does not manage this automatically.
1. Configure the Hidden Service
Edit your torrc file (typically /etc/tor/torrc):
HiddenServiceDir /var/lib/tor/ldk-server/
HiddenServicePort 9735 127.0.0.1:9735
This tells Tor to forward incoming connections on port 9735 of the hidden service to your
node's local Lightning listening port. Adjust the local port to match your
node.listening_addresses config.
sudo systemctl restart torAfter restarting, Tor generates your .onion address:
sudo cat /var/lib/tor/ldk-server/hostnameThis outputs something like abcdef...xyz.onion.
Set the onion address as an announcement address so other nodes can find you:
[node]
listening_addresses = ["localhost:9735"]
announcement_addresses = ["abcdef...xyz.onion:9735"]
[tor]
proxy_address = "127.0.0.1:9050"listening_addresses: the local address your node actually listens onannouncement_addresses: the public address announced to the network (your.onionaddress)proxy_address: needed so your node can also connect outbound to other.onionpeers
After starting LDK Server, confirm your onion address appears in the node info:
ldk-server-cli get-node-infoThe node_uris field should include <node_id>@abcdef...xyz.onion:9735. Other nodes can
now connect to you over Tor using this URI.
You can announce both a clearnet address and an onion address:
[node]
listening_addresses = ["0.0.0.0:9735"]
announcement_addresses = ["203.0.113.1:9735", "abcdef...xyz.onion:9735"]This makes your node reachable over both the public internet and Tor.