1

I've been having a problem connecting to my rabbitmq server when I start it on my local machine. Apparently the erlang cookie of the server, running on my local machine, does not match the cookie on my local machine. I found an old post on the internet explaining that such a problem when running on a local machine can be caused by the fact that I'm not running rabbitmq as a rabbitmq user which is created for you by the installer. So I did just that and started rabbitmq as rabbitmq user, with the following command.

sudo -H -u rabbitmq bash /usr/lib/rabbitmq/bin/rabbitmq-server

How does it really work? Since I don't have a dedicated folder for the user rabbitmq I want to understand where erlang cookie can be saved for the mentioned user, so that it does not match the cookie inside MY home folder (it IS there). Also I would like to know how the command --set-home would work in the context of the given command given such user does not (to my understanding) have a home directory.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
  • 1
    I don't know anything about rabbitmq, but it sounds like you want to know what the user's home directory is set to when you execute the command: if so, you can use `sudo -H -u rabbitmq sh -c 'echo $HOME'` (it's important to use single quotes here). OTOH it's possible that rabbitmq is configured to save the cookie somewhere other than its user's `$HOME` – steeldriver Jan 26 '19 at 13:31
  • That's actually the command I was looking for, thanks! I didn't know you could set a home directory for a user inside the /var/lib. – Alexander Tolub Jan 26 '19 at 21:40

1 Answers1

1

The RabbitMQ installer creates the rabbitmq user and sets the home directory to /var/lib/rabbitmq. You can discover this by looking for the rabbitmq user in /etc/passwd.

Apparently the erlang cookie of the server, running on my local machine, does not match the cookie on my local machine.

How do you know this? Did you run a command and see an error? This is important information.

The way RabbitMQ is intended to be used when installed via a package is to be started by init (systemd) as the rabbitmq user. Then, when you need to run rabbitmqctl, you do so as root and the command switches to the rabbitmq user, ensuring that the correct cookie is used.

You may be able to copy the /var/lib/rabbitmq/.erlang.cookie file to your home directory and run rabbbitmqctl as your own user.


NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

Luke Bakken
  • 111
  • 2
  • I know that the cookie does not match since I looked at the logs that the rabbitmq provides when I try to login with rabbitmqctl. I can't provide the exact error message at the moment, but I searched for that error message and found numerous posts of people telling it's probably caused by the cookie mismatch. So I looked how to rectify that, and eventually came up with an idea to run rabbitmq as the rabbitmq user, which helped. That's how I reached a conclusion that cookie does indeed mismatch. – Alexander Tolub Jan 26 '19 at 21:31