[erlang-questions] reliably figure out hostname

Tim Watson <>
Thu Aug 2 18:58:30 CEST 2012


On 2 August 2012 17:42, JD Bothma <> wrote:
> I remember having to add something to the hosts file of a recent
> ubuntu release before erlang would find out its own hostname properly.
> Not sure if that's related. I'll see if I can dig up more info.
>

Thanks, I appreciate that.

> Does a machine necessarily have a FQDN? Is this necessarily exactly
> one? Perhaps you'll have to work out what erlang does to get some
> hostname and then set the appropriate setting (once) on each relevant
> machine to make sure it gets what you expect it to.
>

Well, the issue is that the testing framework knows nothing about this
issue, but at the moment it does 2 things:

1. on startup, it uses net_kernel:start/1 to become a distributed erlang node
2. when (optionally) connecting to remote nodes (i.e., test subjects)
it uses net_kernel:hidden_connect_node/1

This all works fine for long and short names, as long as the machine
configuration is correct, but there's another catch. When you specify
the test nodes you're going to start, you can optionally provide them
as [{localhost, [node1, node2]}] etc. In *this* case, localhost must
be converted to the correct machine name, and as I said that works
*fine* for shortnames, but for longnames it appears to depend on the
configuration of the machine.

Perhaps as Vlad suggested, this is an insurmountable problem because
of the varying configurations that could exist in different
environments.



More information about the erlang-questions mailing list