[erlang-questions] detection of hostname

Bengt Kleberg <>
Tue Oct 23 07:15:37 CEST 2012


On Solaris the "method to get a host name" is described by the
file /etc/resolv.conf on each computer.


On Mon, 2012-10-22 at 21:53 +0200, Vlad Dumitrescu wrote:
> Hi!
> In erlide we are starting erlang nodes from Java and lately we had
> (and still have some) trouble with retrieving a host name that works.
> The latest versions are starting an erlang node with "erl -name foo"
> and read the hostname used by it. Today I got a report that this
> method is not reliable either: for a machine called "desktop", erlang
> may detect it is on a network and use "desktop.domain.com" as
> hostname. But the DNS might not be able to resolve that name, and it
> may not be in /etc/hosts either. So even if two erlang nodes can
> connect to each other using this name, other programs that use other
> ways to resolve the name can't connect.
> I've been trying hardcoding "localhost" and "" but that makes
> the nodes unreachable from other machines, so one can't reliably do
> RPCs.
> My knowledge about name resolution in networking is poor (just what I
> discovered while fighting this issue), so I'll ask a dumb question:
> isn't there a method to get a host name that can be use in all
> circumstances (when there is one)? That is it should be resolvable by
> the OS, not something made-up from the machine name and the network
> id...
> Or if anybody has a suggestion for another method for starting an
> Erlang node that one can later always connect to, I am open for
> suggestions.
> I could keep adding checks (look for /etc/hosts myself, query the DNS,
> etc), but I can't possibly cover all OSs and all possible network
> configurations. It feels like this is an operation that should have a
> standardized implementation...
> Thanks in advance!
> best regards,
> Vlad
> _______________________________________________
> erlang-questions mailing list
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list