How to connect to my Elixir node on my VPS?

But I can clarify it even more! You’re using distillery, meaning you ran mix release.init to create your release. That created a file under rel/ called vm.args which is read into the release. This is a great place to put options for the erlang runtime, like name or sname. If you look at that file, you’ll see that it already has a name defined, unless you’ve changed it already!

## Name of the node
-name <%= release_name %>@127.0.0.1

You can change -name to -sname there, and only use the first part of the full name, if you prefer. For example replace it with

## Name of the node
-sname mycoolnode

The thread also clarifies that using sname can be more difficult than name, because you might not know what the second part of name@host is. But your mileage might vary.

You want to connect to it using erl -remsh live@my_vps_ip_addr -sname debug@localhost_or_whatever_should_be_here. Note that you wrote -sname debug@localhost_or_whatever but -sname only takes the name, not the host. Compare -sname debug and -name debug@localhost.

You really want something like erl -remsh mycoolnode@ip_address_or_dns_name -sname whatever. And for this to work, the -name part has to be what the remote node calls itself and it has to be accessible from your machine, eg the IP or DNS name. You can figure this out by running bin/my_app remote_console on the remote machine, and then Node.self.

3 Likes