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

I am using django-celery for my django project. Last day I have changed my computer's hostname (I am using Ubuntu 12.04, edited file '/etc/hostname'), and after next restart django-celery was failing with error

Consumer: Connection Error: [Errno 111] Connection refused. Trying again in 4 seconds...

After some research on this error I could find that, changing my host name caused this error from here. My rabbitmq startup log shows

file: /var/log/rabbitmq/startup_log

Activating RabbitMQ plugins ...

********************************************************************************
********************************************************************************

0 plugins activated:

ERROR: epmd error for host "jinesh": nxdomain (non-existing domain)

My startup_err file is empty.

when I run

root@jinesh:/home/jinesh# rabbitmqctl list_users
Listing users ...
Error: unable to connect to node rabbit@jinesh: nodedown

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

nodes in question: [rabbit@jinesh]

hosts, their running nodes and ports:
- unable to connect to epmd on jinesh: nxdomain

current node details:
- node name: rabbitmqctl4956@jinesh
- home dir: /var/lib/rabbitmq
- cookie hash: RGhmB2JR1LbZ57j7xWWTxg==

I hope changing the nodename may fix this issue. But I couldn't found a way to do this. Anyone have idea about how solve this issue?

update

while changing hostname you have to change both /etc/hostname and /etc/hosts files.

I reinstalled rabbitmq and solved this issue, Will answer this question.


Solution 1:

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.

Solution 2:

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.