Connecting two Elixir nodes on different servers (no docker or kubernetes)

Hello, everyone,

I’m using mix release to deploy an app two two servers and am trying to get them connected to each other. I’ve set the following environment variables on each server:

SERVER 1

RELEASE_COOKIE=some_cookie
RELEASE_NODE=app_name@server1.domain.com
RELEASE_DISTRIBUTION=name

SERVER 2

RELEASE_COOKIE=some_cookie
RELEASE_NODE=app_name@server2.domain.com
RELEASE_DISTRIBUTION=name

When I launch both servers and then type the following command from SERVER 1’s iex session:

Node.ping :"app_name@server2.domain.com"

I get :pang as a response, meaning the connection failed. Similarly, if I try:

Node.connect :"app_name@server2.domain.com"

I get false as a return value, which also means the connection failed.

I’m able to ping SERVER 2 from SERVER 1 in Bash, so I know the FQDN is getting resolved correctly, but the Elixir nodes don’t want to talk to each other. I’ve also made sure the environment variables are really set and show up correctly in the iex prompt (e.g., app_name@server2.domain.com).

EDIT: I forgot to mention this earlier, but I have port 4369 open on both machines.

I’m not using Docker or Kubernetes (and have no desire to).

Any ideas (or further information you need from me)?

Have you opened the firewalls? There’s a set of ports that need to be open. Note that node-to-node communication is plaintext by default and opens you up for RCE so I wouldn’t do it except via an SSH tunnel or VPN or other similar solution.

1 Like

Oh, yes. I’m behind a VPN and I’ve opened port 4369 on both machines. Are there any other ports that need to be open?

I think 4369 is only for epmd which communicates the actual ports. You should be able to find the actual ports by running epmd -names.

2 Likes

Thanks for the information. That is good to know.

Since the servers are running mix release builds, Erlang isn’t installed on the servers and I don’t have access to the epmd command. I did open all ports between the two machines just to see if blocked ports is the issue but I am still having connection issues.

I was able to get this working. The problem was a setting in AWS. I wish I could tell everyone what it was, in case someone else has this issue, but the guy managing our AWS account won’t tell us what he changed.

If you run into this problem and you’ve configured your mix release deployments as described in my original post, your side of things is correct. The issue is with your network configuration.

Also, thanks, @Nicd for the valuable information.

1 Like