[erlang-questions] detection of hostname
Tue Oct 23 10:52:06 CEST 2012
This is very annoying and I came up against it myself recently for a systems testing framework Ive been working on. There doesn't seem to be a standard way to do this that will pick up all possible configurations, and the problem is more complicated of you take long names into account. I opted to make the user configure the node and host name (plus short or long names scheme) themselves so that I don't have to worry about it.
On 22 Oct 2012, at 20:53, Vlad Dumitrescu <> wrote:
> 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 "127.0.0.1" but that makes
> the nodes unreachable from other machines, so one can't reliably do
> 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
> 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
> 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,
> erlang-questions mailing list
More information about the erlang-questions