vBlog

vBlog

Useful tips and snippets

25 Apr 2014

Running rabbitmqctl as root

On some Linux distributions, running rabbitmqctl as root may fail with the following error:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    Error: unable to connect to node rabbit@host: nodedown



    DIAGNOSTICS

    ===========



    attempted to contact: [rabbit@host]



    rabbit@host:

      * found rabbit (port 25672)

      * TCP connection succeeded

      * suggestion: hostname mismatch?

      * suggestion: is the cookie set correctly?



    current node details:

    - node name: rabbitmqctl19092@localhost

    - home dir: /root

    - cookie hash: B+onVMMDnR1uRT2nuD24VA==

Assuming that the hostname is correct and running rabbitmqctl as the rabbitmq user works, this is a cookie mismatch problem.

In order to be able to run rabbitmqctl as root, it must use the same cookie as the one used by the server. This cookie is usually found in /var/lib/rabbitmq/.erlang.cookie. To use this cookie, the HOME environment must be set to /var/lib/rabbitmq. Either create a wrapper around /usr/bin/rabbitmqctl that sets the correct environment, or edit this file to add HOME=/var/lib/rabbitmq on the line that starts with exec ${ERL_DIR}.

Tags