rabbtimqadmin - Could not connect: [Errno -2] Name or service not known

霸气de小男生 提交于 2019-12-01 07:03:14

After much digging and frustration, I found my problem... I'm posting the solution in case anyone else has a similar experience

Previously, I found that if you setup RabbitMQ on a linux server then change the hostname that it can break some of the rabbit configuration.

The awesome part about this problem is that someone changed the name of the server from all capital letters to lowercase...

I've solve this one of two ways:

Solution 1:

Revert the host name back to the previous name. So that rabbitmq references with the appended server name work again.

Solution 2:

If you want to keep the server name change, then you can create a rabbitmq-env.conf files in /etc/rabbitmq like:

NODENAME=rabbit@OLDHOSTNAME

If you aren't sure what your previous name was, you can reference it by doing an ls in your /var/lib/rabbitmq/mnesia/ folder. You'll then see a folder that matches the nodename you need to specify.

Reference: https://www.rabbitmq.com/man/rabbitmq-env.conf.5.man.html

UPDATE:

Host name is CaSE SeNSiTIve... had someone change a hostname on me and the only difference was the case... so took a while to notice...

Yesterday I've lost a few hours with this same problem and it was in a fresh install, so the problem was that the erlang cookie from my user and root user was different than the one from rabbitmq user.

  • Find out the HOME for the user rabbitmq:

    # cat /etc/passwd | grep rabbitmq
    
  • Check if the cookies differs from each other:

    # vimdiff /var/lib/rabbitmq/.erlang.cookie ~/.erlang.cookie
    
  • If they are different, copy the cookie from rabbitmq for the user that you want to have access to the server:

    # cp /var/lib/rabbitmq/.erlang.cookie ~/.erlang.cookie
    

References:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!