[erlang-bugs] epmd assumes is always available

Raimo Niskanen <>
Mon Oct 15 11:25:59 CEST 2012

On Sat, Oct 13, 2012 at 10:31:03PM +0200, Thomas Steen Rasmussen wrote:
> Hello guys,
> I am using erlang in a FreeBSD jail for RabbitMQ and I've hit what I
> belive is a wrong assumption in epmd. FreeBSD jails do not have
> available. Instead you normally add the jails IP as
> localhost in /etc/hosts to help software that connects to localhost
> find the correct IP to use.
> However in the case of erlang, in line 198 of erl_epmd.erl:
> https://github.com/erlang/otp/blob/maint/lib/kernel/src/erl_epmd.erl#L198
> The localhost IP is assumed to be I believe this should be
> a DNS lookup of the name "localhost" to accomodate systems without a
> IP.
> When I patched line 198 in erl_epmd.erl to use the jails IP instead of
>, and added the jails IP as "localhost" in /etc/hosts, it
> worked like a charm. Before the change, I got the following error when
> trying to start rabbitmq: http://pastebin.com/Aw4Bd7wm
> I am by no means an erlang expert, in fact today may be the first
> time I've really looked at erlang code, so making the change myself
> might be a bit much for me. But what do you think ? Do you agree that
> this can be considered a bug ?

Note that it is a much more common problem that the hostname "localhost"
does not resolve to the right address and that the user has no power
to change that name resolving.

Somtimes "localhost" resolves to an external IP address, sometimes
to, sometimes to depending on OS and installation.
And, of course ::1.

There are C API constants that could/should be used instead i.e
INADDR_LOOPBACK, IN6ADDR_LOOPBACK_INIT. From Erlang code you can use
the atom 'loopback' instead of an address and it will be translated
in the inet driver to one of those C API constants.

Using an IP address is often safer than relying on the resolver.
If is not a loopback address of a machine there are
usually more things than epmd that breaks.

Often you want epmd and all erlang nodes to use the loopback
address, keeping all Erlang nodes behind the host firewall.

> Best regards,
> Thomas Steen Rasmussen
> ps. Someone just reminded me that this wouldn't work in an ipv6 only
> environment either, just one more reason to make the change :)
> _______________________________________________
> erlang-bugs mailing list
> http://erlang.org/mailman/listinfo/erlang-bugs


/ Raimo Niskanen, Erlang/OTP, Ericsson AB

More information about the erlang-bugs mailing list