Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect Elixir nodes on MacBook Pro

Tags:

elixir

I can’t seem to connect two nodes on my macbook pro. I am using iex —sname foo and iex —sname bar in two separate terminal sessions and they can’t see each other. I’ve tried setting the firewall and turning it off completely with no luck.

From foo, I am using Node.self to see that the full name is :"foo@ewHBook-Pro" and then from bar, I’m trying both Node.connect :"foo@ewHBook-Pro" and Node.ping :"foo@ewHBook-Pro"

like image 247
ewH Avatar asked Nov 13 '15 16:11

ewH


3 Answers

Hostname resolution is a bit tricky on OSX. Try using long names with --name "foo". If that fails, explicitly tell it the hostname you want to use with:

--name "foo@`hostname`"

The name will then be something like :"[email protected]" and you can use that in Node.connect/1 and Node.ping/1.

like image 134
zyro Avatar answered Nov 06 '22 04:11

zyro


This is likely an issue in your hosts file. Check out this comment by pma on this GitHub issue.

The solution on the issue was using iex --sname foo@localhost and iex --sname bar@localhost.

like image 25
Gazler Avatar answered Nov 06 '22 05:11

Gazler


sudo vi /etc/hosts

then add a line

127.0.0.1    macbook

the macbook is your computer name.

like image 1
LJZN Avatar answered Nov 06 '22 04:11

LJZN