I have BTCPay server and would like to use external c-lightning node which i have funded and prefer more over BTCPay server local docker container (DC).

In store configuration i see that there is option to connect to c-lightning over tcp or unix socket (this one is used when i connect internal node because c-lightning DC socket is linked to BTCPay directly).

screenshot of store LN payment configuration menu

How can i connect over TCP? As i uderstand this is not public nodes port (9735) which is used to communicate between nodes but some API port? How can i enable it on c-lightning? Is data sent plain and i should secure communication (lan, fw, vpn etc.)?

  • Can't give you the full answer but a hint. Unix domain sockets are local. So you could only connect to a Unix domain socket on that machine / within that docker container. One way is you could migrate your external lightning node inside your dicker container. Shut it down and copy ./lightning dir. I am however sure there is a more elegant way. Also you will most likely not talk to your c Lightning node via port 9735 on tcp as that is what is used on the lightning network. It is new to me that clightning offers a tcp api. Which is the reason I could only comment here and not answer May 1, 2019 at 15:36
  • yeah, i see your point. i thought about "sharing" exactly lightning-rpc socket file over ssh or smth similar if its possible to share unix domain socket over lan at all. i have btcpay server and c-lightning on separate physical hosts in same lan, but would like to prefer not to move one into another if its possible. i also could not find any mention about tcp listeners in lightningd help..
    – baysx
    May 1, 2019 at 15:41
  • Just a word of caution. In case you decide to migrate the node make sure to really migrate the latest channel state and don't run two seperate instances with the same files in the lightning-dir as this will most certainly produce channel beaches with lots of funds May 1, 2019 at 17:14

1 Answer 1


Port 9735 is the lightning port. What BTCPay wants is the API. C-Lightning does not support TCP natively, but one can use socat as I did in the docker entrypoint to bridge unix to TCP.

  • I'll add additional description if anyone like me will be searching for direct steps there are two ways to connect: 1) use socat. install and run command socat TCP-LISTEN:22345 UNIX-CONNECT:/path/to/.lightning/lightning-rpc 2) as suggested before, use github.com/ElementsProject/lightning-charge
    – baysx
    May 3, 2019 at 8:35
  • But what is the EXPOSE_TCP setting for then? I'm confused. I created a new question specifically about that, so that one of you can reap the benefits of answering another question. :) bitcoin.stackexchange.com/questions/88862/…
    – gijswijs
    Jul 5, 2019 at 8:07
  • EXPOSE_TCP just mean that the container is running socat to expose RPC over TCP. Aug 19, 2019 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.