k-p
Connecting Livebook to a node on a remote docker container
I have an Elixir app running on a remote server using Dokku. I’d like to connect to it from my local machine using Livebooks, via a SSH tunnel.
I can’t seem to make the remote container visible to my local Livebook.
I’ve tried the top StackOverflow comments and have tried setting RELEASE_NODE, RELEASE_NAME, and RELEASE_DISTRIBUTION. I have RELEASE_COOKIE configured and am using this.
I have tried using RELEASE_NODE as <app_name>@localhost, <app_name>@127.0.0.1, and <app_name>@<server_ip>.
I gather there’s some shenanigans trying to get EPMD to see the remote node. I’ve tried setting ERL_DIST_PORT to 9000, forwarding Dokku’s host 9000 to the container’s 9000, and opening an SSH tunnel with 9000 open.
Is there a straightforward-ish solution or problem I’m missing? I appreciate there’s a few moving parts.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security










Most Liked
jonatanklosko
@_jonas you linked to
ERL_EPMD_PORTenv var, which indeed sets the port for epmd to listen on. However, the-erl_epmd_portflag sets the node distribution port. The fact that they are named the same is unfortunate, however in recent OTP the flag has been deprecated in favour of kernel application parameter namederl_epmd_node_listen_port, which is more accurate.jonatanklosko
Hey @k-p! There are a few elements
The remote node needs to start distribution on a known port. I believe
ERL_DIST_PORTis used by rebar3/relx, not the Elixir releases. To force a specific port you can doELIXIR_ERL_OPTIONS="-erl_epmd_port 9000"(or pass it in vm.args).The distribution port needs to be forwarded to a local port, let’s assume it’s the same.
The remote node needs to have 127.0.0.1 hostname (or if it uses a domain name, you can edit your local
/etc/hoststo resolve it to 127.0.0.1).With the above steps, the node appears as if it was running locally. However, the missing piece is that the local EPMD doesn’t know about this node. You can register the node manually by running this script:
Make sure to change the node name at the end, it should be the base name, without the hostname part. The registration is kept until you kill the script.
Technically steps 3. and 4. could be done by using a custom EPMD module, but since we are talking about Livebook, the solution assumes no changes to the EPMD module. (In fact, Livebook already uses a custom EPMD for a similar purpose).
jonatanklosko
Just to make sure, you are using
RELEASE_DISTRIBUTION=name,RELEASE_NODE=app@127.0.0.1and the same cookie?This is correct. The argument name is confusing, and in fact it’s going to change in the next OTP version. It is supposed to set the port that the node uses for distribution, not the EPMD port itself. So
name app at port 9000looks good.If the connection is refused, the only thing I can think of is something with the forwarding. For the ssh forwarding maybe try
127.0.0.1and notlocalhost, unless you already do that. Otherwise it could be the port forwarding to Docker.Last Post!
_jonas
Ah, that is good to know!
I thought when running without epmd, there would be some way to manually specify the distribution port of another node to connect to, similar to how you would normally specify the name.
I guess I was mistaken – then I suppose your suggested way of running with a local epmd and registering the remote node manually is indeed the best option, thanks again for explaining.