Connecting erlang nodes

Tuesday, 17th May, 2011

In order to connect to each other, erlang nodes each need a name, they need to share a secret cookie, and if they’re to communicate over the internet, they need access to ports.

The secret cookie can be either set at runtime (as in the examples below), or in each user’s .erlang.cookie file.

For local connection

On the same machine or subnet, each node just needs a short name:

$ erl -sname chico -setcookie marx

For internet connection

Each node must have the following ports available:

  • port 4369, used by epmd (the Erlang Port Mapper Daemon, not Erick and Parrish Making Dollars), must be open for both TCP and UDP (n.b.: this is a default).
  • another port or range of ports for the erlang nodes themselves. These nodes can be set at run time using the -kernel, inet_dist_listen_min and inet_dist_listen_max flags.

Each node must also use a full name, with either a domain or an IP address:

$ erl  -name  -setcookie longrandomstring  -kernel inet_dist_listen_min 9000  inet_dist_listen_max 9005


Erlang nodes are gregarious: as soon as nodes find out about each other, they connect. An easy way to say hello is “ping”:

(chico@localhost)1> nodes().
(chico@localhost)2> net_adm:ping(groucho@localhost).
(chico@localhost)3> nodes().                        
(chico@localhost)4> ^g
User switch command
 --> r groucho@localhost
 --> c
Eshell V5.7.2  (abort with ^G)

You can skip the connection palaver by using the -remsh flag at startup:

$ erl -sname chico -setcookie marx -remsh groucho@localhost


Introspection GUIs like AppMon and Pman can access any connected node (see the Nodes menu in the toolbar).

One Response to “Connecting erlang nodes”

  1. […] you’re connected to the above node (see Connecting erlang nodes), you can run rb, the report browser. A little bit of set up is required. See this discussion on […]

Leave a Reply to Browsing error logs on a remote node « absolute regularity Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: