If you run a c-lightning node with EXPOSE_TCP set to True, it seems to me it should be possible to connect with it remotely, provided that the c-lightning RCP is listening to all incoming traffic. (IP is set to

I tried the Docker setup recommended in the c-lightning readme and when I use socat to connect directly from inside the Docker container everything works smooth:

socat - UNIX-CONNECT:/home/simnet/.lightning/lightning-rpc

But when I try to use socat from the container host the connection closes directly upon opening with no error or anything:

socat - tcp:

The ports seem to be mapped correctly>9835/tcp

I don't understand what I am missing here. Is it even possible to connect remotely with this setup? I've read this question as well, and the answer suggests to use socat inside the Docker container to bridge the Unix socket to TCP, but it seems to me that the EXPOSE_TCP is meant to do exactly that natively.

UPDATE: The API doesn't really seem to be exposed over TCP after all, although the parameter is certainly set to True. This is how I found out:

  • I wasn't even able to use the API over TCP from inside the docker container
  • Then I bridged the Unix socket to TCP manually by using socat. socat -d -d TCP-LISTEN:9835,fork,reuseaddr UNIX-CONNECT:/home/user/.lightning/lightning-rpc
  • After this I was able to connect to the lignting-c node remotely.

So maybe there's something wrong with c-lightning in interpreting this setting, or maybe there's something wrong with my setup. I'll explore further and report back.

  • 1
    Technically speaking the EXPOSE_TCP setting is part of the btcpayserver setup, not c-lightning itself. Looking at the entrypoint script (github.com/ElementsProject/lightning/blob/…) it appears that the comparison with EXPOSE_TCP is case-sensitive, so maybe you have used something other that true (all lower-case)?
    – cdecker
    Jul 7, 2019 at 12:17
  • @cdecker I found the culprit. Thank you for the input.
    – gijswijs
    Jul 8, 2019 at 1:24

2 Answers 2


You are likely missing a port-binding to your docker image. Since you are able to connect to the port from inside the docker container socat seems to be working.

In order to expose the TCP port to the host OS you need to add -p 9835:9835 to your docker command line. That will map the host port 9835 to redirect everything to the guest port 9835, hence making it reachable from the host through the IP which is localhost from the host's point of view.

  • No, that can't be it. The ports are already mapped. If I run docker ps I get this output:>9835/tcp. If I then try to run socat - tcp: on the host nothing happens and the connection closes on itself directly.
    – gijswijs
    Jul 6, 2019 at 12:43

EXPOSE_TCP is implemented in c-lightning's docker script:



If you didn't use that script or didn't implement it in your own docker script, it won't work.

It's easy to mistake EXPOSE_TCP for a parameter you can set when spinning up c-lighting.

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.