[erlang-questions] Different hostname from erl -sname and inet:gethostname()

Magnus Klaar magnus.klaar@REDACTED
Mon Sep 26 01:51:38 CEST 2011


Hi!

The inet:gethostname() function returns the name of the system that the node
is running on. This is the name that is printed by the hostname command.
This persistent configuration data is not stored in the /etc/hosts, but in
the /etc/hostname file.

The presence of your hostname in the /etc/hosts file is to ensure that the
local system is reachable at the loopback address, if needed.

If you always want to start a node on localhost and use short names you can
use use slave:start("localhost", slave_node, []).

MVH Magnus

2011/9/26 Ignas Vyšniauskas <baliulia@REDACTED>

> Hi erlang-questions,
>
> I have the following behaviour:
>
> [~]$ erl -sname foobar
> Erlang R14B (erts-5.8.1) [source] [64-bit] [smp:4:4] [rq:4]
> [async-threads:0] [hipe] [kernel-poll:false]
>
> Eshell V5.8.1  (abort with ^G)
> (foobar@REDACTED)1> inet:gethostname().
> {ok,"pufpuf"}
>
> Notice the different 'localhost' and 'pufpuf' hostnames.
>
> I am running Erlang R14B-2 on ArchLinux 3.0.
>
> [~]$ hostname
> pufpuf
>
> [~]$ cat /etc/hosts
> #<ip-address>   <hostname.domain.org>   <hostname>
> 127.0.0.1       localhost.localdomain   localhost    pufpuf
> ::1             localhost.localdomain   localhost
>
> Is it normal behaviour? I am using things like:
>
> {ok, Hostname} = inet:gethostname(),
> slave:start(Hostname, slave_node, []).
>
> which obviously fails under such circumstances.
> Is there a different approach to this? Is my system misconfigured?
>
> /Ignas
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110926/f47c5615/attachment.htm>


More information about the erlang-questions mailing list