First bits
As I said in a previous post, I'm learning Erlang via Joe Armstrong's book: Programming Erlang. This post is probably only meaningful if you caught the same error - if not, and you read it to the end, I tip my hat to you!
The error
In chapter 10, Distributed Programming, I hit a small snag following along with the Name Server example.
As instructed I start the first of the two nodes:
$erl -sname gandalf
Erlang (BEAM) emulator version 5.5.4 [source]
[async-threads:0] [kernel-poll:false]
Eshell V5.5.4 (abort with ^G)
(gandalf@loulou)1> kvs:start().
true
(gandalf@loulou)2>
And then the second:
$erl -sname bilbo
Erlang (BEAM) emulator version 5.5.4 [source]
[async-threads:0] [kernel-poll:false]
Eshell V5.5.4 (abort with ^G)
(bilbo@loulou)1>
So far so good, although I notice the shell has picked up the computer name loulou instead of localhost (although it's not mentioned anywhere in /etc/hosts - someone might like to explain to me how this works).
Continuing on with the example:
(bilbo@loulou)1> rpc:call(gandalf@localhost, kvs, store, [weather, fine]).
=ERROR REPORT==== 27-Jun-2007::18:28:22 ===
Error in process <0.38.0> on node 'bilbo@loulou' with exit value:
{badarg,[{erlang,list_to_existing_atom,["gandalf@loulou"]},
{dist_util,recv_challenge,1},
{dist_util,handshake_we_started,1}]}
{badrpc,nodedown}
(bilbo@loulou)2>
"Weird" says I, but having noticed the node registered as @loulou I figure it's worth a shot:
(bilbo@loulou)2> rpc:call(gandalf@loulou, kvs,store, [weather, fine]).
{badrpc,nodedown}
(bilbo@loulou)2>
Plenty of surfing the interwebs ensued, all to no avail. Eventually I tried:
$erl -sname gandalf@localhost
Erlang (BEAM) emulator version 5.5.4 [source]
[async-threads:0] [kernel-poll:false]
Eshell V5.5.4 (abort with ^G)
(gandalf@localhost)1> kvs:start().
true
(gandalf@localhost)2>
%%
$erl -sname bilbo@localhost
Erlang (BEAM) emulator version 5.5.4 [source]
[async-threads:0] [kernel-poll:false]
Eshell V5.5.4 (abort with ^G)
(bilbo@localhost)1>
Which changes the node name to look exactly like the example. Voila! The example works as expected:
(bilbo@localhost)1> rpc:call(gandalf@localhost, kvs,store, [weather, fine]).
true
(bilbo@localhost)2> rpc:call(gandalf@localhost, kvs, lookup, [weather]).
{ok,fine}
I only wish the weather were actually fine - it's pouring here in Melbourne!
PS: I'm sorry for the lame syntax highlighting - I'm too lazy to write a function to switch it off. Maybe later...

Feed
Comments 6
Thanks for the post. I just encountered the same error on my MBP. I had an even more bizarre experience because my host name contains a dash (user-mac). So when it showed up in the initial error messages and I tried to send the rpc to gandalf@user-mac, Erlang thought I was trying to subtract numbers and started giving me weird badarith messages. Anyhow, issue solved.
By the way, I tried going through the steps on a my linux box and after starting gandalf and bilbo and getting the error messages, things worked fine when I tried with gandalf@<realhostname>. go figure.
Posted August 3, 2007 at 12:24 p.m. ¶That is weird! Are you doing anything exciting with Erlang, or just messing around?
Posted August 9, 2007 at 4:22 p.m. ¶Thanks for the hint, I had the same problem.
Posted September 26, 2007 at 1:51 a.m. ¶No worries Ben :)
Posted September 27, 2007 at 9:10 a.m. ¶Thanks for this post. I was trying to get @localhost message passing working with the Getting Started guide on the Erlang website. It will not work as the default bind seems not to be on 0.0.0.0. Passing @localhost into -sname did the trick solving two problems: 1) having a node name of @user-macbookpro, and 2) trying to just use localhost to test distributed erlang on the same machine.
Posted November 11, 2007 at 2:46 p.m. ¶Glad to help Jeff!
Posted November 13, 2007 at 10:20 a.m. ¶Comments are now closed.