0

I have installed RabbitMQ on my laptop. I start the server (rabbitmq-server -detached) and then rabbitmqctl start_app, and things work fine (my Java application can connect and send/receive messages).

$ rabbitmqctl start_app
Starting node 'rabbit@11-020-7206' ...

But when I go to another place, where the network is different, the laptop gets another hostname and I cannot do anything with it anymore. If I try to stop or start it, I get an error that node is down.

$ rabbitmqctl stop
Stopping and halting node 'rabbit@Mahdis-MacBook-Pro' ...
Error: unable to connect to node 'rabbit@Mahdis-MacBook-Pro': nodedown

DIAGNOSTICS
===========

attempted to contact: ['rabbit@Mahdis-MacBook-Pro']

rabbit@Mahdis-MacBook-Pro:
  * connected to epmd (port 4369) on Mahdis-MacBook-Pro
  * epmd reports node 'rabbit' running on port 25672
  * TCP connection succeeded but Erlang distribution failed
  * suggestion: hostname mismatch?
  * suggestion: is the cookie set correctly?
  * suggestion: is the Erlang distribution using TLS?

current node details:
- node name: 'rabbitmq-cli-14528@Mahdis-MacBook-Pro'
- home dir: /Users/mahdi
- cookie hash: HBqyY/jYPLAyrH1wt3dTWQ==

If I try to start the server altogether, it says node is running:

$ rabbitmq-server -detached
Warning: PID file not written; -detached was passed.
ERROR: node with name "rabbit" already running on "Mahdis-MacBook-Pro"

How can I fix the hostname to avoid this confusion?

Mahdi
  • 1,778
  • 1
  • 21
  • 35

2 Answers2

0

You started rabbitmq node as 11-020-7206 then you changed the hostname (related to the network) as Mahdis-MacBook-Pro.

Generally you should always have the same hostname, but if it is not possible you can use rabbitmqctl -n node_name

Here an example:

gabrielesMacBookPro:sbin gabriele$ ./rabbitmqctl status
Status of node rabbit@gabrielesMacBookPro ...
[{pid,59273},
 {running_applications,
     [{rabbitmq_management,"RabbitMQ Management Console","3.5.5"},
     ...

Here I change the host name:

gabrielesMacBookPro:sbin gabriele$ sudo hostname temp_hostname
Password:
gabrielesMacBookPro:sbin gabriele$ ./rabbitmqctl status
Status of node rabbit@temp_hostname ...
Error: unable to connect to node rabbit@temp_hostname: nodedown

DIAGNOSTICS
===========

attempted to contact: [rabbit@temp_hostname]

In this way I can connect to the running node:

gabrielesMacBookPro:sbin gabriele$ ./rabbitmqctl -n rabbit@gabrielesMacBookPro status
Status of node rabbit@gabrielesMacBookPro ...
[{pid,59273},
 {running_applications,
     [{rabbitmq_management,"RabbitMQ Management Console","3.5.5"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.5.5"},

hope it helps

Gabriele Santomaggio
  • 21,656
  • 4
  • 52
  • 52
  • Thanks Gas. The hostname changes automatically when I move from one place to the other. I will try your suggestion (when I am at the other place) and will let you know if it works. – Mahdi Sep 30 '15 at 09:51
  • Your solution does not work. If I provide the previous name `rabbit@11-020-7206` then it fails even earlier `unable to connect to epmd (port 4369) on 11-020-7206: nxdomain (non-existing domain)`. Nevertheless, if I change the hostname like you did, rabbitmq works again. – Mahdi Sep 30 '15 at 20:40
0

Inspired by the suggestion of @Gas, I found a workaround. If I change the hostname back to what it was before moving the laptop to the second location, rabbitmq (and its tools) start working again.

$ sudo hostname 11-020-7206
$ rabbitmqctl status
Status of node 'rabbit@11-020-7206' ...
[{pid,16230},
 {running_applications,[{rabbit,"RabbitMQ","3.5.4"},
....
Mahdi
  • 1,778
  • 1
  • 21
  • 35