rabbitmqrabbitmqctl

sudo rabbitmqctl status gives Error and also takes time to responde


I get this error when i run sudo rabbitmqctl status on an on-prem server specifically on rhel8


Error: unable to perform an operation on node 'rabbit@xxxxx'. Please see diagnostics information and suggestions below.
 
Most common reasons for this are:
 
* Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)

* CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)

* Target node is not running
 
In addition to the diagnostics info below:
 
* See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more

* Consult server logs on node rabbit@xxxxxx

* If target node is configured to use long node names, don't forget to use --longnames with CLI tools
 
DIAGNOSTICS

===========
 
attempted to contact: ['rabbit@xxxxx']
 
rabbit@xxxxx:

  * connected to epmd (port 4369) on xxxxxxx

  * epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic

  * can't establish TCP connection to the target node, reason: timeout (timed out)

  * suggestion: check if host 'xxxxxxxx' resolves, is reachable and ports 25672, 4369 are not blocked by firewall
 
Current node details:

* node name: 'rabbitmqcli-401-rabbit@xxxxx'

* effective user's home directory: /var/lib/rabbitmq

* Erlang cookie hash: gvMlNMNDWrRk2xONh+tqWQ==

 Documentation: Table of Contents
 — RabbitMQ

Erlang version = Erlang/OTP 25 Rabbitmq version = 3.12.12 latest

How can i fix this error?

I attempted to establish TCP connections to the ports 25672, 4369, 5671, and 15672 using the nc command, and the connections were successful.

Additionally, I pinged the hostname/IP address to verify if it is reachable.


Solution

  • Check the Erlang cookie on the RabbitMQ server The default location of the cookie is: /var/lib/rabbitmq/.erlang.cookie

    cat /var/lib/rabbitmq/.erlang.cookie
    

    Copy the cookie to the user’s home directory Use sudo to copy the cookie to the home directory of the user running rabbitmqctl, for example, the dam01 user:

    sudo cp /var/lib/rabbitmq/.erlang.cookie /home/dam01/.erlang.cookie
    

    Set the appropriate permissions for the cookie Ensure that only the owner can read the file by setting the permission to 400

    sudo chmod 400 /home/dam01/.erlang.cookie
    

    Update the /etc/hosts file Edit the /etc/hosts file to map 127.0.0.1 to your hostname:

    sudo vi /etc/hosts
    

    Add or modify the following line:

    127.0.0.1 hostnamexxxxxx
    

    Restart RabbitMQ server & Check status Stop, start & verify the RabbitMQ server:

    sudo rabbitmq-server stop
    sudo rabbitmq-server start
    sudo rabbitmqctl status