Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rabbitmq-server fails to start after hostname has changed for first time

People also ask

Why RabbitMQ is not working?

Make sure the node is running using rabbitmq-diagnostics status. Verify config file is correctly placed and has correct syntax/structure. Inspect listeners using rabbitmq-diagnostics listeners or the listeners section in rabbitmq-diagnostics status. Inspect effective configuration using rabbitmq-diagnostics environment.

How do I find my RabbitMQ hostname?

The default hostname of RabbitMQ is set to rabbitmq@SERVER-IP and the default home is /opt/bitnami/rabbitmq/rabbitmq_home. Change this in the /opt/bitnami/rabbitmq/etc/rabbitmq/rabbitmq-env. conf file.

How do I start RabbitMQ when it crashes due to insufficient space?

Resolving The Problem. Remove the file /var/lib/rabbitmq/mnesia/rabbit@host-name/recovery. dets if the size is 0 and restart RabbitMQ by running 'systemctl start rabbitmq-server.


Remove the old installation of RabbitMQ to fix this problem. Here are steps to reinstall RabbitMQ. These commands are run as the root user:

  1. Stop RabbitMQ: rabbitmqctl stop

  2. Change /etc/hosts

  3. Change /etc/hostname

  4. Uninstall old RabbitMQ: dpkg -P rabbitmq-server

  5. Remove RabbitMQ’s database: rm -rf /var/lib/rabbitmq

  6. Find erlang’s process that is running rabbit: ps ax | grep rabbit

  7. Kill the listed process

  8. Reinstall RabbitMQ: apt-get install rabbitmq-server

I wrote about these steps on my blog.

REVISION

I moved my blog to a new website.


Thanks to Richard H Fung.

His steps helped me to solve this issue.

But I did not have to re-install the rabbitmq.

When I opened my /etc/hosts file I found that IP assigned to my hostname is different than the actual ip(192.168.1.200 [static]).

#/etc/hosts  
127.0.0.1       localhost  
192.168.1.115   HOSTNAME

so I just changed IP address to 192.168.1.200 in my /etc/hosts file and it worked fine.


Richard's answer is good, but you might lose some information in the rabbitmq queues. The following is a possible way to preserve the previous setup of rabbitmq with the new host name.

A Short Answer:

If you want to keep the new host name change, then you can create a rabbitmq-env.conf files in /etc/rabbitmq that references the old host name and all should be good. The following is what should be in the rabbitmq-env.conf file:

NODENAME=rabbit@OLDHOSTNAME

After adding the config file, restart the rabbitmq server then you should be good. (e.g. service rabbitmq-server restart (might need a sudo with ubuntu))

For more details you can read from the rabbitmq website: https://www.rabbitmq.com/man/rabbitmq-env.conf.5.man.html

More Details About the Answer:

I had a similar hostname issues using CentOS... The root issue was when rabbit installs, it references the current host name at the time of install. Since this is a rabbitmq thing, the solution should work for other linux flavors. If you want to see the full answer, you can see it at: rabbtimqadmin - Could not connect: [Errno -2] Name or service not known


You could solve this problem by either deleting the erlang mnesia database associated with rabbitmq or reinstalling rabbitmq.

I got hint for first solution from rabbitmq mailing list. Excerpt from answer, The Erlang Mnesia database is host specific (because it is a distributed DB). The simplest way to get you fixed is to clear out the database dir.

The second method is the easiest way (not recommend though). To uninstall do

dpkg -P rabbitmq-server

You can refer this link if you would like to know more about installing/removing debian packages.


On Windows, the issue I was facing was due to the McAfee firewall. The exact error was:

epmd error for host "<HOSTNAME>": address (cannot connect to host/port)

It started working as soon as I disabled the firewall