[erlang-questions] net_kernel:start/1 doesn't honor ERL_EPMD_PORT set by os:putenv/2

Zandra Hird <>
Tue Mar 15 13:29:18 CET 2016

Hi Khitai,

net_kernel:start is looking at the init value of the EPMD port (the one 
specified when erlang was started), so changing the environment variable 
in Erlang like this doesn't have any effect. I agree that it would 
probably be more intuitive if it worked as you describe, so please 
submit a feature request to bugs.erlang.org <http://bugs.erlang.org> (or 
if you have found any documentation saying that it should work as you 
say, please submit it as a bug and point to the documentation), and 
we'll look into it as soon as we get time to do so.

If you want to contribute with a change for this, which you are very 
welcome to do, please look at the code in lib/kernel/src/erl_epmd.erl. 
Make sure to think it through though, for example by handling the case 
when the port environment variable is changed when the distribution is 
already started. :)

Best Regards,

On 03/11/2016 05:48 AM, Khitai Pang wrote:
> Hi,
> I have the following code:
> os:putenv("ERL_EPMD_ADDRESS", inet_parse:ntoa(IP)),
> os:putenv("ERL_EPMD_PORT", integer_to_list(5555)),
> os:cmd("epmd -daemon"),
> net_kernel:start([bob, longnames]),
> The ERL_EPMD_ADDRESS and ERL_EPMD_PORT environment variables are used 
> by os:cmd("epmd -daemon") but net_kernel:start/1 fails:
> Protocol: "inet_tcp": register/listen error: econnrefused
> Apparently it still tries to connect to 4369, where no process is 
> listening.
> If I start erl by "ERL_EPMD_PORT=5555 erl", net_kernel:start/1 in the 
> above code works fine.
> So I have come to the conclusion that environment variables set by 
> os:putenv/2 are not honored by net_kernel:start/1.  Am I right? If 
> yes, 1) is this a bug? 2) for a Erlang/OTP release, how to 
> automatically set global environment variables for erl?
> Thanks
> Khitai
> _______________________________________________
> erlang-questions mailing list
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160315/c00c6731/attachment.html>

More information about the erlang-questions mailing list